f111fei / react-native-unity-view

Show an unity view in react native
MIT License
402 stars 102 forks source link

Best way to reload Unity view? #32

Open halileohalilei opened 6 years ago

halileohalilei commented 6 years ago

Is there a way to reload the whole view, together with the running Unity instance? Unmounting and mounting the view doesn't seem to work since my Unity application just resumes instead of restarting. I also tried reloading the scene from Unity, but that's not what I'm really after. Any help or hint on this would be greatly appreciated.

f111fei commented 6 years ago

Reload must destroy unity player first. You have some scenes that need to be reloaded? Maybe you can try to pause and resume view instead of reload.

halileohalilei commented 6 years ago

The thing is, I'm using a library that needs camera permissions, and since the permission is not granted the first time the user opens my app, this library throws exceptions at each frame. Even if I reload the scene, the exceptions don't go away, probably because the library does some static initialization when its loaded into memory. There doesn't seem to be anything wrong after reopening the app after granting the camera permissions. So I thought reloading the whole Unity instance might solve this issue.

I also wrote to the people maintaining the library, but any solution to this problem is enough for me.

aflahkp commented 3 years ago

Any updates?

shhhiiiii commented 2 years ago

I used Application.Unload(); to unload unity and navigate to other react native screen, When navigate again to unity view, Unity will reload just fine and will work properly,

But the problem is that messaging is distorted. Unity still can send message and will be receive in react native side, But for react native part when attempt to send message to unity view. Unity will not be able to receive the message.

Im suspecting that react native still trying to send message from the previous view that has been unload.

Does anyone know how to fix this problem?

PLEASE HELP. Thanks!!