Examples & Templates
Learn Game Framework through hands-on examples and production-ready templates. From simple demos to advanced patterns, these examples will help you master Unity-Flutter integration.
Getting Started with Examples
Unity Template Scripts
Game Framework includes Unity template scripts that demonstrate key patterns and features. Sync them to your Unity project:
# Sync core scripts only
game sync scripts
# Include template examples
game sync scripts --templatesFlutter Example App
The framework includes a complete Flutter example application:
# Clone the repository
git clone https://github.com/xraph/gameframework.git
# Navigate to example
cd gameframework/example
# Run the example
flutter runAll examples include both Unity and Flutter code, so you can see the complete integration!
Available Examples
Rotating Cube Demo
Interactive 3D demo with touch controls, speed adjustment, and color customization
Messaging Patterns
String, JSON, and typed messaging with request-response patterns
Binary Data Transfer
Send and receive images, files, and binary data with compression support
High-Frequency Messaging
Performance testing with throughput measurement and latency tracking
State Synchronization
Full state sync with delta compression and periodic broadcasting
Scene Management
Load and unload scenes with async progress tracking
Flutter Example App
Complete Flutter app demonstrating all framework features
What You'll Learn
Beginner Examples
Perfect for getting started:
- Rotating Cube - Bidirectional communication basics
- Messaging Patterns - Different ways to send messages
- Flutter Example App - Complete integration walkthrough
Intermediate Examples
Build on the basics:
- Binary Data Transfer - Working with images and files
- Scene Management - Managing Unity scenes from Flutter
- State Synchronization - Keep Flutter and Unity in sync
Advanced Examples
Performance and optimization:
- High-Frequency Messaging - Optimize for high throughput
- State Synchronization - Delta compression and efficient updates
Example Structure
Each example includes:
- Unity Script: Complete C# implementation
- Flutter Code: Dart integration code
- Setup Instructions: Step-by-step guide
- What You'll Learn: Key concepts covered
- Code Walkthrough: Detailed explanations
Quick Start
1. Sync Template Scripts
cd your_flutter_project
game sync scripts --templates2. Open Unity
Add the scripts to your Unity scene:
- Open Unity Editor
- Create a new GameObject
- Attach the example script (e.g.,
GameFrameworkDemo.cs) - Press Play to test in Unity
3. Integrate with Flutter
Use the Flutter code snippets from each example to communicate with Unity.
Template Scripts Overview
GameFrameworkDemo.cs
Interactive rotating cube with bidirectional communication. Perfect first example.
Key Features:
- Touch-based rotation controls
- Speed adjustment from Flutter
- Color customization
- Real-time feedback
What You'll Learn: Basic messaging, parameter updates, event handling
MessagingExample.cs
Comprehensive messaging patterns demonstration.
Key Features:
- String messages
- JSON/typed messages
- Request-response pattern
- Event broadcasting
What You'll Learn: All message types, type safety, async patterns
BinaryDataExample.cs
Binary data transfer for images and files.
Key Features:
- Image upload to Unity
- Screenshot capture from Unity
- Chunked transfers
- Compression
What You'll Learn: Binary protocol, performance optimization
HighFrequencyDemo.cs
Performance testing and optimization.
Key Features:
- Throughput measurement
- Latency tracking
- Batching effectiveness
- Throttling
What You'll Learn: Performance optimization, profiling
StateManager.cs
State synchronization patterns.
Key Features:
- Full state sync
- Delta compression
- Periodic updates
- Versioning
What You'll Learn: Efficient state management
SceneController.cs
Unity scene management from Flutter.
Key Features:
- Load/unload scenes
- Async loading
- Progress tracking
- Multi-scene support
What You'll Learn: Scene lifecycle, async operations
Example Projects
Basic Integration
Start with the rotating cube:
# Sync templates
game sync scripts --templates
# Run Flutter app
flutter runComplete Demo App
Run the full example application:
git clone https://github.com/xraph/gameframework.git
cd gameframework/example
flutter runLearning Path
Step 1: Rotating Cube
Start here to learn basic communication.
Step 2: Messaging Patterns
Explore different message types.
Step 3: Binary Data
Learn to transfer images and files.
Step 4: Scene Management
Control Unity scenes from Flutter.
Step 5: State Synchronization
Implement efficient state updates.
Step 6: Performance Testing
Optimize for production use.
Follow the examples in order for the best learning experience. Each builds on concepts from previous examples.
Getting Help
Example Issues
If you encounter problems with examples:
- Check the Troubleshooting Guide
- Review Unity Setup
- See FAQ
Community
Next Steps
Ready to dive in?
- Start with the Rotating Cube - Your first interactive example
- Explore Messaging Patterns - Learn communication methods
- Run the Flutter Example - See a complete integration
All template scripts are production-ready and can be used as starting points for your own projects!