Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure & load multiple unity gradle exports in one react native project #145

Open
adikhadilkar opened this issue Mar 20, 2020 · 0 comments

Comments

@adikhadilkar
Copy link

Hey,

I have successfully integrated the Gradle export of a Unity project in a React native project.

I am able to load the exported Unity module on click of a react native button as well as I can communicate with the unity module through a react native project & vice a versa.

Is there any way to add multiple gradle exports (multiple unity projects) in one react native project & achieve communication between them (one unity project / module at a time only) ?

I have tried a few things. I am not sure if it is the right way of solving this issue.

  1. I have added 2 gradle exports of 2 different unity projects in android directory of my app

  2. I have included path of these 2 gradle exports in android/settings.gradle file

    include ':react-native-unity-view'
    project(':react-native-unity-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-unity-view/android')

    include ":UnityExport"
    project(":UnityExport").projectDir = file("./UnityExport")

    include ":UnityExport1"
    project(":UnityExport1").projectDir = file("./UnityExport1")

  3. I have also added the dependency of second unity export in node_modules/react-native-unity-view/android/build.gradle file

    dependencies {
    compile project(':UnityExport')
    compile project(':UnityExport1')
    compile 'com.facebook.react:react-native:+'
    }

To load unity module we generally create an instance of UnityView in our .js file

import UnityView, {UnityModule} from 'react-native-unity-view';
React.createElement(UnityView, {
style: {position: 'absolute', left: 0, right: 0, top: 0, bottom: 0},
onUnityMessage: this.onUnityMessage.bind(this),
});

Can anyone please tell me

  1. if we can integrate multiple unity module within a react native project?
  2. if we can, then how should we load those modules on click of separate react native buttons?

relevant references / help / example codes is appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant