game scaffold
Create a complete Flutter plugin package that wraps gameframework with minimal boilerplate. Includes a game engine project, example app, and pre-configured build settings.
Usage
game scaffold [options]Interactive Mode (Recommended)
Run without arguments for guided setup:
game scaffoldYou'll be prompted for:
- Package name (with validation)
- Organization (e.g., com.mycompany)
- Game engine selection (Unity or Unreal)
- Project template (Example or Minimal)
- Target platforms
- Description (optional)
- Output directory
Interactive mode is the easiest way to scaffold - just follow the prompts!
Non-Interactive Mode
Provide all options via flags:
game scaffold \
--name my_game \
--org com.mycompany \
--engine unity \
--project-template example \
--platforms android,iosOptions
| Option | Description | Default |
|---|---|---|
--name, -n | Package name (must be valid pub.dev name) | (prompted) |
--org | Organization/domain (e.g., com.mycompany) | com.example |
--engine | Game engine: unity or unreal | (prompted) |
--project-template | Project template: example or minimal | example |
--platforms | Target platforms (comma-separated) | android,ios |
--description | Package description | (optional) |
--output, -o | Output directory | ./<package_name> |
What Gets Created
my_game_package/
├── unity_project/ # Your Unity game project
│ ├── Assets/
│ ├── ProjectSettings/
│ └── ...
├── android/ # Minimal plugin registration
├── ios/ # Minimal plugin registration
├── lib/
│ ├── my_game_package.dart # Re-exports gameframework
│ └── src/game_widget_wrapper.dart # Optional convenience wrapper
├── example/ # Example Flutter app
│ ├── lib/main.dart
│ └── ...
├── .game.yml # Export configuration
├── pubspec.yaml # Depends on gameframework packages
└── README.mdTemplates
Example Template
Includes a full-featured sample project:
- Complete Unity/Unreal demo scene
- Sample scripts with communication examples
- Working example Flutter app
- Pre-configured for immediate use
Minimal Template
Creates a basic starter project:
- Empty Unity/Unreal project
- Essential scripts only
- Minimal example app
- Ready for customization
Examples
Create Unity Package
# Interactive (recommended)
game scaffold
# Non-interactive
game scaffold \
--name my_unity_game \
--engine unity \
--project-template exampleCreate Unreal Package
# With minimal template
game scaffold \
--name my_unreal_game \
--engine unreal \
--project-template minimal \
--platforms android,ios,macosCustom Organization
game scaffold \
--name awesome_game \
--org io.awesome \
--engine unity \
--description "My awesome game package"Development Workflow
After scaffolding:
# 1. Navigate to package
cd my_game/
# 2. Open game project in editor
open unity_project/ # or unreal_project/
# 3. Make changes in Unity/Unreal
# 4. Export game builds
game export unity --platform android,ios
# 5. Sync exported files to Flutter
game sync unity --platform android,ios
# 6. Test in example app
cd example/
flutter run -d android
# 7. Publish when ready
cd ..
game publishUsing the Generated Package
In your Flutter app:
import 'package:my_game/my_game.dart';
// Option 1: Use convenience wrapper
MyGameWidget(
onEngineCreated: (controller) {
controller.sendMessage('Hello!');
},
onMessage: (message) {
print('From engine: ${message.data}');
},
)
// Option 2: Use GameWidget directly (re-exported from gameframework)
GameWidget(
engineType: GameEngineType.unity,
config: const GameEngineConfig(
androidPlatformViewMode: AndroidPlatformViewMode.virtualDisplay,
runImmediately: true,
),
)Key Features
No Custom Implementation
The scaffold creates a thin wrapper that:
- Depends on
gameframeworkand engine-specific packages - Re-exports gameframework APIs for convenience
- Contains minimal plugin registration code only
- All engine logic stays in gameframework packages
Includes Game Project
Choose between:
- Example template: Full-featured sample project from repo
- Minimal template: Basic starter project with essential scripts
Ready to Publish
Generated package is ready to:
- Use in Flutter apps immediately
- Publish to pub.dev
- Publish to Game Framework Cloud
Package Structure
Plugin Registration (Android)
Minimal Kotlin code for plugin registration:
package com.example.my_game
import io.flutter.embedding.engine.plugins.FlutterPlugin
class MyGamePlugin: FlutterPlugin {
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
// Plugin registration only
}
}Plugin Registration (iOS)
Minimal Swift code for plugin registration:
import Flutter
import UIKit
public class MyGamePlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
// Plugin registration only
}
}Dart Library
// my_game_package.dart
library my_game;
// Re-export gameframework
export 'package:gameframework/gameframework.dart';
export 'package:gameframework_unity/gameframework_unity.dart';
// Optional convenience wrapper
export 'src/game_widget_wrapper.dart';Configuration (.game.yml)
The scaffold generates a pre-configured .game.yml:
name: my_game
version: 1.0.0
engines:
unity:
project_path: ./unity_project
export_path: ./unity_project/Exports
platforms:
android:
enabled: true
target_path: android/unityLibrary
ios:
enabled: true
target_path: ios/UnityFramework.frameworkTroubleshooting
Invalid Package Name
Error: Package name must be a valid pub.dev package name
Solution: Use lowercase letters, numbers, and underscores only. Start with a letter.
Good: my_game, awesome_package_3d
Bad: MyGame, my-game, 3d_package
Template Download Failed
Error: Failed to download template
Solutions:
- Check your internet connection
- Verify GitHub access
- Try again after a moment
- Use minimal template if example fails
Directory Already Exists
Error: Output directory already exists
Solutions:
- Choose a different output directory with
--output - Remove the existing directory
- Use a different package name
Related Commands
game add engine- Add engine to existing projectgame export- Export game buildsgame sync- Sync exported filesgame publish- Publish package
Next Steps
After scaffolding:
- Export your game with
game export - Sync to Flutter with
game sync - Test the example with
flutter run - Publish to cloud with
game publish
The scaffold command is perfect for creating publishable game packages!