SDK Documentation
SDK Quick Start
Learn the basics of the Game Framework SDK with this quick tutorial.
Installation
Add the SDK packages to your pubspec.yaml:
dependencies:
gameframework: ^0.0.1
gameframework_unity: ^0.0.1flutter pub getInitialize the Plugin
In your main.dart:
import 'package:flutter/material.dart';
import 'package:gameframework/gameframework.dart';
import 'package:gameframework_unity/gameframework_unity.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
// Initialize Unity plugin
UnityEnginePlugin.initialize();
runApp(MyApp());
}Create a GameWidget
class GameScreen extends StatefulWidget {
@override
State<GameScreen> createState() => _GameScreenState();
}
class _GameScreenState extends State<GameScreen> {
GameEngineController? _controller;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('My Game')),
body: GameWidget(
engineType: GameEngineType.unity,
config: GameEngineConfig(
runImmediately: true,
fullscreen: false,
),
onEngineCreated: (controller) {
setState(() => _controller = controller);
print('Engine created!');
},
onMessage: (message) {
print('Message: ${message.data}');
},
),
);
}
}Send Messages to Engine
FloatingActionButton(
onPressed: () {
_controller?.sendMessage(
'GameManager', // Target object
'StartGame', // Method name
'level1', // Data
);
},
child: Icon(Icons.play_arrow),
)Receive Messages from Engine
onMessage: (GameEngineMessage message) {
if (message.target == 'Flutter') {
switch (message.method) {
case 'GameOver':
showDialog(/*...*/);
break;
case 'ScoreUpdated':
setState(() => score = message.data);
break;
}
}
}Lifecycle Management
@override
void dispose() {
_controller?.dispose();
super.dispose();
}That's it! You now have a Flutter app with game engine integration.
Next Steps
- Unity Integration - Unity-specific setup
- API Reference - Complete API docs
- Messaging Guide - Advanced communication