We are working on creating a Unity game with a large UI component. We are considering using React Native for the UI. Do you know if this is possible?
Did you manage to do this?
Thinking of doing the same, any thoughts?
Finally after a lot of trials managed to do this. These are the steps.
-
- Using this 1, export android project for Gradle.
Select Gradle in the Build Settings window and check the Export Project checkbox.
Click Export and select the destination folder.
- Using this 1, export android project for Gradle.
-
- Import the generated folder in Android studio. Select ok whenever prompted. In this process, you will encounter following issues
- 2a) Gradle Sync Failed due to org.gradle.api.internal.tasks issues. Resolve using this 2
-
- Create React Native App using this 3
-
- Start Integrating Android exported folder inside created react native app using this 4. Don’t upgrade Gradle as Android Studio will ask you again and again. You will encounter following issues. Don’t go through “Test Integration” until you are finished with #5 here.
- 4a) While configuring Maven, use this url for Maven url “$rootDir/…/node_modules/react-native/android” .
- 4b) While configuring maven if you encounter a problem related to javax.inject:javax.inject". Use this 5.
- 4c) You may also encounter this error “Conflict with dependency ‘com.google.code.findbugs:jsr305’”. You can solve it using this 6.
- 4d) During Code integration section of this link, focus on the following section: If you are using a starter kit for React Native, replace the “HelloWorld” string with the one in your index.android.js file (it’s the first argument to the AppRegistry.registerComponent() method). Here you have to replace with the project name.
-
- Before going through “Test your Integration” section, you have to add code to call MyReactActivity from UnityActivity. This 7 will help.
-
- Go through “Test your Integration” section of link provided in #4. You may encounter following problems.
- 6a) unable to load script from assets index.android.bundle. Use this 8.
- 6b) could not connect to development server on android. Use this 9.
I created an example project of how to do this for Android: GitHub - marijnz/unity-react: An example setup to run React Native on top of Unity3D for Android.