A comprehensive example demonstrating the GameFramework capabilities.
This example app showcases:
- Engine Initialization - Proper setup of Unity engine plugin
- Lifecycle Management - Automatic pause/resume/destroy handling
- Bidirectional Communication - Flutter ↔ Unity message passing
- Event Logging - Real-time event stream monitoring
- UI Controls - Control panel for testing engine operations
- Flutter 3.10.0 or higher
- Unity 2022.3.x (for building Unity content)
- Android SDK or Xcode (for mobile testing)
-
Install dependencies:
flutter pub get
-
Run on Android:
flutter run -d android
-
Run on iOS:
flutter run -d ios
-
Run on Web:
flutter run -d chrome
- Game Widget - Full-screen Unity game integration
- Control Panel - UI for sending messages and testing operations
- Event Log - Real-time display of engine events
- Debug Console - Message history and debugging tools
The example demonstrates:
// Initialize Unity engine
UnityEnginePlugin.initialize();
// Embed game in Flutter UI
GameWidget(
engineType: GameEngineType.unity,
onEngineCreated: (controller) {
// Engine ready - send initial message
controller.sendMessage('GameManager', 'Start', 'level1');
},
onMessage: (message) {
// Handle messages from Unity
print('Unity says: ${message.data}');
},
)To test with actual Unity content:
- Create a Unity project (2022.3.x)
- Add Flutter bridge scripts from
engines/unity/plugin/ - Build for Android/iOS using Flutter > Export for Flutter
- The exported build will be integrated automatically
See the Unity Plugin Guide for details.
This is expected - the example runs with a mock Unity instance. To test with real Unity content, follow the Unity Project Setup steps above.
- Android: Ensure Android SDK is installed and configured
- iOS: Requires Xcode and CocoaPods
- Web: WebGL builds require additional setup (see WEBGL_GUIDE.md)
MIT License - see LICENSE file for details.