Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native with Unity

Does anyone have any experience combining React Native and Unity? I'm looking to start a Unity project that's very UI Heavy and I'm thinking about using React Native to take advantage of its UI capabilities on mobile and web.

I'm curious what the workflow for such an approach would be.

like image 276
Jimmy Xu Avatar asked Oct 16 '15 16:10

Jimmy Xu


People also ask

Can I use Unity in react native?

Now Unity is configured and ready Now you can export the Unity Project using ReactNative => Export Android or ReactNative => Export IOS . Then the exported artifacts will be placed in a folder called UnityExport inside either the android or the ios folder.

Can we use react in Unity?

Yes, We can integrate Unity in to React using Native Components for both iOS and Android. So, that we can use the same development of unity in React and also we can communicate from React to Unity.

Can you use flutter with Unity?

Now you can make awesome gamified features of your app in Unity and get it rendered in a Flutter app both in fullscreen and embeddable mode. Works great on Android, iPad OS, iOS, Web, with Windows nearing completion.

What is Unity as a library?

How it works. Unity offers controls that let you manage when and how to load/activate/unload the runtime library within the native application. Beyond that, the mobile app build process mostly stays the same. Unity lets you create iOS Xcode and Android Gradle projects.


Video Answer


1 Answers

Finally after a lot of trials managed to do this. These are the steps.

  • 1) Using this link, 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.
  • 2) 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 link
  • 3) Create React Native App using this link
  • 4) Start Integrating Android exported folder inside created react native app using this link. 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 problem related to javax.inject:javax.inject". Use this link.
  • 4c) You may also encounter this error "Conflict with dependency 'com.google.code.findbugs:jsr305'". You can solve this link.
  • 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 project name.
  • 5) Before going through "Test your Integration" section, you have to add code to call MyReactActivity from UnityActivity. This link will help.
  • 6) 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 link.
  • 6b) could not connect to development server on android. Use this link.
like image 100
Shaunak Das Avatar answered Sep 18 '22 00:09

Shaunak Das