सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
Unity_Kit एक Flutter प्लगइन है जो Flutter प्रोजेक्ट में Unity 3D गेम और एप्लिकेशन के सहज एकीकरण की अनुमति देता है। यह Flutter और Unity के बीच कार्यकुशल संचार के लिए टाइप किए गए ब्रिज और बाइनरी प्रोटोकॉल प्रदान करता है, जिससे उच्च प्रदर्शन सुनिश्चित होता है। AR विशेषताओं का समर्थन करता है और Android, iOS, Web, Windows, Linux और macOS पर संगत है। ऐसे डेवलपर्स के लिए आदर्श है जो Flutter की UI क्षमताओं को Unity के शक्तिशाली 3D रेंडरिंग और गेम लॉजिक के साथ जोड़ना चाहते हैं।
उपयोग
Flutter ऐप्स में Unity 3D गेम्स को एम्बेड करना
Flutter और Unity के साथ AR अनुभव बनाना
क्रॉस-प्लेटफॉर्म 3D सामग्री डिलीवरी
समृद्ध ग्राफिक्स के साथ हाइब्रिड ऐप विकास
फ्लटर वर्कफ़्लो में मौजूदा यूनिटी संपत्तियों को एकीकृत करना
यूनिटी का उपयोग करने वाले गेम डेवलपर जो फ्लटर यूआई चाहते हैं
क्रॉस-प्लेटफॉर्म इंटरैक्टिव अनुभव बनाने वाली टीमें
उच्च प्रदर्शन वाले 3D रेंडरिंग की आवश्यकता वाले प्रोजेक्ट
आधुनिक Flutter ऐप में पुराने Unity प्रोजेक्ट को एकीकृत करने वाले विकासकर्मी
विचार योग्य बातें
Unity प्रोजेक्ट सेटअप और कॉन्फ़िगरेशन की आवश्यकता है
परिपक्व प्लगइन्स की तुलना में सीमित दस्तावेज़न
Flutter और Unity के बीच राज्य को प्रबंधित करने में संभावित जटिलता
यूनिटी रनटाइम के कारण ऐप का आकार बढ़ सकता है
पूर्ण डेप्लॉयमेंट के लिए प्लेटफ़ॉर्म-विशिष्ट बिल्ड चरणों की आवश्यकता होती है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Unity Kit
A Flutter plugin for Unity 3D integration. Embed Unity content in Flutter apps with typed communication, lifecycle management, asset streaming, and support for Unity 2022.3 LTS through Unity 6.
📚 Documentation
Full hosted documentation — a complete zero-to-running walkthrough, native setup guides, API reference and troubleshooting — lives at codigee.com/open-source/unity-kit.
Flutter handles UI (screens, buttons, navigation). Unity handles 3D (rendering, game logic). They run in the same app but are separate worlds -- they talk by sending JSON messages through a native bridge.
Flutter (Dart) Unity (C#)
UI, screens, JSON messages 3D rendering,
business logic <=========================> game logic
native bridge (iOS/Android)
There are no direct method calls. Everything goes through serialized JSON over the platform bridge. Flutter never calls C# directly, and Unity never calls Dart directly.
Repository Structure
.├──unity_kit/# Flutter plugin package (published to pub.dev)│├──lib/# Dart source code│├──android/# Android native layer (Kotlin)│├──ios/# iOS native layer (Swift)│├──unity/# C# scripts for Unity side│├──example/# Example Flutter app│├──test/# Test suite (35 files, 640+ tests)│└──doc/# API reference & asset streaming guide├──doc/# Detailed guides│├──unity-export.md# Step-by-step Unity export guide│├──unity_integrations.md# Content loading methods (scenes, Addressables, etc.)│├──android-integration.md# Android native architecture & known issues│├──ios-integration.md# iOS native architecture & known issues│└──architecture.md# Overall architecture overview└──.github/workflows/# CI/CD (auto-tag + pub.dev publish)
Key Features
Feature
What it does
Typed Bridge
UnityMessage objects instead of raw strings. Structured, type-safe communication.
Copy unity_kit/unity/Assets/Scripts/UnityKit/ into your Unity project. A FlutterBridge GameObject auto-creates on scene load and handles all communication.
// Receive messages from Flutter
public class MyHandler : FlutterMonoBehaviour
{
protected override void OnFlutterMessage(string method, string data)
{
switch (method)
{
case "StartGame":
// do something
NativeAPI.SendToFlutter("{\"type\":\"game_started\"}");
break;
}
}
}
For downloading 3D content from a server at runtime:
1. Flutter downloads content_manifest.json from CDN
2. User selects a toy/asset in the UI
3. Flutter downloads the .bundle file to local cache (SHA-256 verified)
4. Flutter tells Unity: "cache is at /path" (SetCachePath)
5. Flutter tells Unity: "load asset with key 'alphie'" (LoadToyRemote)
6. UnityAddressables loads from local cache (not from network again)
7. Unity sends "toy_loaded" back to Flutter
Building Addressables
Setup (one-time):Flutter > Setup Addressables
Add asset: place prefab in Addressables group, set address key
See doc/faq.md for the full list. Here are the top issues:
Black screen after Unity loads (Android)
Unity needs an explicit "refocus" after attaching to the view: windowFocusChanged(true) + pause() + resume(). This is handled by unity_kit automatically. If you see a black screen, check that you're using the latest version.
Touch not working (Android)
Unity's New Input System requires InputDevice.SOURCE_TOUCHSCREEN on touch events. The UnityContainerLayout in unity_kit fixes this. If touch doesn't work, make sure you're not overriding the touch handling.
White/blank screen (iOS)
Usually a timing issue: Unity's Metal renderer needs a non-zero view frame before initialization. unity_kit polls with waitForNonZeroFrame(). If it persists, ensure the UnityView widget has a non-zero size in the layout.
Release build works differently than debug (Android)
ProGuard/R8 can strip classes used via reflection or JNI. unity_kit's Build.cs auto-adds ProGuard keep rules during export. If you see silent failures in release, verify proguard-unity.txt contains keep rules for com.unity_kit.** and com.unity3d.player.**.
Messages not reaching Unity / Flutter
Check FlutterBridge GameObject exists in the first scene
Check your handler's target name matches what Flutter sends
Check Unity Console for [UnityKit] No handler registered for target: xxx
On iOS: verify UnityKitNativeBridge.mm is in Assets/Plugins/iOS/
Environment preflight
Before mounting a view, ask what the build actually carries:
final env = awaitUnityKitPlatform.instance.environment();
if (!env.isReadyForUnity) {
// No Unity runtime in this build: a UnityView would come up blank.debugPrint(env.summary);
}
if (env.failsPageSizeRequirement) {
// Google Play rejects updates targeting Android 15+ whose native// libraries are aligned to less than 16 KB.debugPrint('Not 16 KB aligned: ''${env.unalignedLibraries.map((l) => l.name).join(', ')}');
}
env.summary prints a single line for logs, for example:
The Unity 6 class rename.env.runtime says which player class was
found, so a build that silently shipped without the Unity libraries is
obvious instead of showing up as an empty surface.
16 KB page sizes. Since 1 November 2025, Google Play requires every
native library in an app targeting Android 15 (API 35) or newer to be
aligned to 16 KB. Unity satisfies this from 2022.3.56 and from
Unity 6, but an app can still ship an older prebuilt .so. The check
reads the p_align of each PT_LOAD segment out of the shipped files, so
it reports the binary's truth rather than the Unity version's claim.
iOS reports the runtime and page size but no alignment verdict: the 16 KB
rule is an Android packaging requirement.
Unity 6 compatibility
unity_kit uses reflection to detect Unity 6's UnityPlayerForActivityOrService class automatically. No manual configuration needed. If you're using Unity 6 and see issues, check the Android Integration guide for constructor signature details.
Roadmap to 1.0
3D model loading utilities and prefab management helpers
Full step-by-step tutorial covering the complete integration flow
Additional example scenes and sample Unity project