A production-ready integration workflow demonstrating seamless communication between React Native and Unity, including:
- Unity ↔ React Native bridge communication
- Scene management via native messaging
- Android IL2CPP build fixes
- Gradle pipeline customization
- NDK / SDK environment setup
- Release APK workflow
- Wireless debugging setup
Author: Nikhil Chaudhary
Project Type: React Native + Unity Integration Prototype
Platform: Android
Unity Version: Unity 6 (6000.x LTS)
Rendering Pipeline: Universal Render Pipeline (URP)
This project demonstrates a complete integration pipeline between a React Native application and an embedded Unity experience.
The system allows React Native to:
- Launch Unity scenes
- Send commands directly to Unity
- Control gameplay flow from React Native UI
- Return back from Unity to React Native seamlessly
The implementation focuses on:
- Stability
- Scalable bridge architecture
- Production-ready Android builds
- Reliable IL2CPP compilation
- Mobile deployment workflows
✅ React Native ↔ Unity communication bridge
✅ Dynamic scene loading from React Native
✅ IL2CPP Android support
✅ Custom Gradle IL2CPP build task
✅ NDK 27 support
✅ Android API 34 compatible
✅ Multi-ABI support (ARMv7 + ARM64)
✅ Wireless debugging support
✅ Production-ready APK pipeline
✅ Scene-based gameplay launcher
✅ Persistent Unity bridge manager
✅ Decoupled architecture between app layers
| Technology | Purpose |
|---|---|
| React Native | Main mobile application |
| Unity 6 | Embedded game engine |
| TypeScript | React Native logic |
| C# | Unity gameplay bridge |
| IL2CPP | Native Unity compilation |
| Gradle | Android build pipeline |
| Android SDK | Android development |
| Android NDK | Native IL2CPP toolchain |
Before building the project, configure the environment exactly as shown below.
C:\Program Files\Java\jdk-17.0.12
C:/Users/Unity/AppData/Local/Android/Sdk
Add both:
%JAVA_HOME%\bin
%ANDROID_SDK_ROOT%\platform-tools
| Tool | Version |
|---|---|
| JDK | 17 |
| NDK | 27.1.12297006 |
| Node.js | v18 or v20 |
| Unity | Unity 6 |
| Android API | API 34+ |
Open:
File → Build Settings → Android
Enable:
Export Project
IL2CPP
.NET Framework
ARMv7
ARM64
Create an Empty GameObject named:
UnityBridge
Attach:
BridgeController.cs
This object becomes the permanent communication bridge between React Native and Unity.
The Unity bridge handles:
- Incoming React Native commands
- Scene loading
- UI updates
- Persistent runtime communication
- Multi-scene support
React Native
│
├── postMessage()
│
▼
UnityBridge GameObject
│
├── LoadSpecificLevel()
│
▼
SceneManager.LoadSceneAsync()
│
▼
Scene UI Updates
The React Native application acts as the launcher and UI layer.
The app handles:
- Main menu UI
- Unity lifecycle management
- Scene selection
- Bridge communication
- Exit handling
- Device UI management
unityRef.current.postMessage( 'UnityBridge', 'LoadSpecificLevel', sceneName );
(GameObjectName, MethodName, Parameter)
Example:
('UnityBridge', 'LoadSpecificLevel', 'Scene1')
React Native Button
│
▼
UnityView Mounted
│
▼
postMessage Sent
│
▼
UnityBridge Receives Command
│
▼
Scene Loads
│
▼
UI Updates
The Unity activity runs inside its own Android process:
android:process=":Unity"
Benefits:
- Better memory isolation
- Improved app stability
- Cleaner Unity lifecycle management
Prevent Unity bridge stripping during release builds:
-keep class com.azesmwayreactnativeunity.** { *; }
A custom Gradle task manually controls:
- IL2CPP execution
- NDK path mapping
- ABI compilation
- Environment variables
- Native library generation
Default Unity exports can fail during React Native integration because:
- Gradle loses NDK references
- Environment variables are not propagated correctly
- IL2CPP compilation becomes unstable
- Multi-ABI builds fail intermittently
The custom Gradle task uses:
ProcessBuilder
to directly invoke:
il2cpp.exe
with controlled environment variables.
Gradle Build
│
▼
Custom BuildIl2CppTask
│
▼
ProcessBuilder
│
▼
IL2CPP Native Compilation
│
▼
libil2cpp.so Generated
│
▼
APK Packaging
The project compiles:
armeabi-v7a
arm64-v8a
Benefits:
- Wider Android compatibility
- Better performance on modern devices
- Google Play compliance
Check connected devices:
adb devices
Run the app:
npx react-native run-android
Navigate:
cd android
Clean project:
./gradlew clean
Build release APK:
./gradlew assembleRelease
Generated APK location:
android/app/build/outputs/apk/release/app-release.apk
Open Developer Menu by shaking the device.
Open:
Settings → Debug server host
Enter:
192.168.x.x:8081
Replace with your local machine IP.
Run Metro Bundler and test over WiFi.
The project follows a layered architecture.
React Native Layer
│
├── UI Navigation
├── Scene Selection
├── Unity Lifecycle
└── Native Bridge Calls
│
▼
Unity Native Bridge
│
├── Scene Loading
├── UI Updates
├── Persistent Runtime
└── Gameplay Logic
│
▼
Android Native System
│
├── Gradle Pipeline
├── IL2CPP Build System
├── NDK Toolchain
└── APK Packaging
React Native handles:
- Mobile UI
- Navigation
- Native controls
Unity handles:
- Rendering
- Gameplay
- Scene management
DontDestroyOnLoad() ensures:
- Stable communication
- Cross-scene persistence
- Reduced initialization overhead
Unity uses:
SceneManager.LoadSceneAsync()
Benefits:
- Smooth transitions
- Non-blocking scene loading
- Better mobile performance
Custom Gradle scripting ensures:
- Reliable IL2CPP builds
- Controlled environment setup
- Multi-architecture compilation
ReactNativeProject/
│
├── android/
├── ios/
├── src/
├── App.tsx
└── package.json
UnityExport/
│
├── unityLibrary/
├── launcher/
└── gradle/
This project demonstrates:
- Native bridge communication
- Unity embedding inside React Native
- Android IL2CPP troubleshooting
- Gradle automation
- NDK environment management
- Mobile build optimization
- Cross-platform architecture
- Production Android deployment
- Scene-based Unity control systems
The project is optimized for:
- Reduced bridge overhead
- Stable Unity lifecycle handling
- Async scene loading
- Native IL2CPP performance
- Android memory isolation
- ABI compatibility
| Feature | Extension Approach |
|---|---|
| Multiplayer | Add Socket.IO or Photon |
| Authentication | Firebase Auth |
| Save System | Cloud Firestore |
| Analytics | Firebase Analytics |
| Push Notifications | FCM |
| Asset Streaming | Addressables |
| Deep Linking | React Navigation + Native Modules |
| Live Events | Remote Config |
This project provides a complete production-ready workflow for integrating Unity into a React Native mobile application.
It covers:
- Environment setup
- Native bridge communication
- Scene management
- Android build fixes
- IL2CPP compilation
- Gradle automation
- APK generation
- Wireless debugging
The architecture is designed to be scalable, maintainable, and stable for real-world mobile applications that combine React Native and Unity together.
Nikhil Chaudhary
React Native & Unity Developer
This project is provided for educational and development reference purposes.
⭐ Feel free to explore my repositories and connect with me. I’m always open to discussions around Unity development, React Native integration, mobile architecture, IL2CPP pipelines, and scalable game systems.