f111fei / react-native-unity-demo

103 stars 80 forks source link

iOS Message / Unity view enabled as default #10

Closed vpsantos closed 5 years ago

vpsantos commented 6 years ago

I am able to run the demo, that is working fine on Android, but on iOS the message isn't received from Unity. Am I missing something?

I also would like to have the Unity view starting already enabled instead of clicking on "Toggle Unity", but just changing the state.renderUnity to true doesn't work.

Any idea? My Unity version is 2017.4.0f1 and React Native is 0.53.0.

Thanks!

f111fei commented 6 years ago

https://github.com/f111fei/react-native-unity-view/commit/075ea3d1e01497b43b32de2c1a597936098d3e19

Try update react-native-unity-view to 1.1.2 ?

vpsantos commented 6 years ago

Thanks f111fei, but I am already using the package 1.1.2.

The UnityView enabled by default is working for me now, just the message from Unity isn't working on iOS only.

Here is the UnityView code:

<UnityView ref={ref => (this.unity = ref)} style={{ position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, }} onUnityMessage={this.onUnityMessage.bind(this)} />

And here the onUnityMessage function:

onUnityMessage(hander) { this.setState({ clickCount: this.state.clickCount + 1 }); setTimeout(() => { hander.send('I am click callback!'); }, 2000); }

The clickCount is updated properly on Android, but not on iOS.

Any idea?

vpsantos commented 6 years ago

Hi f111fei, I also noticed that on Android the UnityView is rendered by default only if I change the device orientation or shake it to show the developer menu. Is there any option to "force" it to be loaded without any event as on iOS?