azesmway / react-native-unity

MIT License
250 stars 60 forks source link

Re-Mount Unity view with rect-navigation stack #105

Open ManuSense opened 6 months ago

ManuSense commented 6 months ago

Using UnityView with react-navigation stack, the first time the stack screen is mounted UnityView load correctly. If then you go to another screen and go back to the Unity one the UnityVieew component doesn't get rendered. I saw a similar issue here: #15 and so i set the prop androidKeepPlayerMounted?: boolean to true. That solved the issue, but caused another one: when from unity screen you go back to a previous screen and after that you return to the unity screen i got the following error:

The specified child already has a parent. You must call removeView() on the child's parent first. addViewInner (ViewGroup.java) addView (ViewGroup.java) addUnityViewToGroup (ReactNativeUnity.java) ...

Any idea how to solve this?

serdarcevher commented 6 months ago

I have exactly the same issue in Android. Do you have any idea about how to solve this "The specified child already has a parent" issue? @azesmway

serdarcevher commented 5 months ago

This issue goes away when I use the default stack navigator instead of the native one.

However, this time I got an FPS drop problem (in the device camera) when remounting Unity in Android. It's working fine on iOS though.

rafaelsalves commented 1 month ago

Hi, there! So, I investigate the problem, and i found that the lib call a routine that "clear" unity after unmount event. So i forked this lib and remove this. Another point, I added a listener to detect that a screen lost the focus and unmount the components that have unity view embedded. So, now works, I have several screens that have unity view, and i can navigate between them.