Open Source

Flutter package

unity_kit

Embed Unity 3D in Flutter with a typed, testable bridge — JSON or binary protocol, an enforced lifecycle, AR Foundation, and CDN asset streaming. Runs on Android and iOS (web/WebGL experimental).

v2.0.222.6k / month21 likesMITUnity 2022.3 LTS → Unity 6

Overview

What unity_kit is

unity_kit is a Flutter plugin that embeds Unity 3D content inside Flutter apps as a native platform view — Android and iOS in production, with web/WebGL and desktop as experimental scaffolding. Flutter and Unity are separate worlds that communicate through serialized JSON — or a compact binary protocol — over a native bridge. The plugin wraps this in a typed, stream-based Dart API with an enforced lifecycle state machine, a readiness guard that queues messages until Unity is up, and a full asset-streaming pipeline (CDN manifest + SHA-256-verified cache + Unity Addressables).

Why not flutter_unity_widget?

unity_kit was built to fix the long-standing architectural problems of flutter_unity_widget, backed by 670+ Dart tests plus Unity EditMode tests:

  • Controller dying on navigation
  • Silently dropped messages
  • No lifecycle management
  • No Unity 6 support

Typed two-way bridge

UnityBridge + UnityMessage with broadcast streams (messageStream, sceneStream, lifecycleStream, performanceStream) instead of stringly-typed calls.

Binary protocol (2.0)

sendBinary() + UnityBinaryCodec compact wire format for high-frequency traffic, locked by cross-language golden tests on both sides.

Robust lifecycle

Enforced state machine (uninitialized → ready → paused → resumed → disposed) with typed exceptions; the bridge survives widget rebuilds and navigation.

Readiness guard

sendWhenReady() queues messages before Unity is up and auto-flushes on engine start — nothing is silently dropped.

Asset streaming

StreamingController downloads bundles from a CDN manifest, verifies SHA-256, caches locally, and loads via Unity Addressables or raw AssetBundles (~100 MB app instead of a GB-sized APK/IPA).

Unity 2022.3 LTS → Unity 6

Reflection-based player creation (UnityPlayer and UnityPlayerForActivityOrService) — no manual configuration.

One-menu Unity export

Build.cs adds a 'Flutter' menu that exports Android/iOS/WebGL library artifacts, patches Gradle (Groovy + Kotlin DSL), adds ProGuard rules, and can auto-deploy or run headless in CI.

AR & performance

AR Foundation (UnityConfig.ar() with passthrough/overlay modes), transparent iOS rendering, a performance stream (FPS / frame time / memory), and [UnityKitMethod] attribute dispatch on the C# side.

Documentation

Browse the docs

Every guide below mirrors a document in the repository, so the website and the repo never drift apart. Start with the step-by-step guide if you are integrating for the first time.

Let's make something together.

If you have any questions about a new project or other inquiries, feel free to contact us. We will get back to you as soon as possible.

Codigee
We are using cookies. Learn more