azesmway / react-native-unity

MIT License
272 stars 66 forks source link

Start Unity while unfocussed and pause it when it's reached a satisfactory start state #128

Open SethCram opened 2 months ago

SethCram commented 2 months ago

Hi @azesmway thanks for maintaining this repo!!

I recently upgraded from v0.3.1 to v1.0.10, and I noticed that previously, my Unity game would start loading by default even when not focused, requiring a manual pause on mount. In the new version, I'm looking for a way to manually enable this behavior while keeping androidKeepPlayerMounted={true}, as I need it to see my Unity game. My Unity content is in a separate screen that loads in the background when a tab navigator is first initialized, but since the Unity tab isn't the first one focused, I'd like the game to load in the background so it's ready at scene 1 when first navigated to. However, I've tried using unityRef.current.resumeUnity(); and unityRef.current.windowFocusChanged(true); when the tab is mounted, but neither approach has worked on Android. So far, the only way I've managed to start the game is by manually focusing the tab.

IhsotasTon commented 2 months ago

same here, confused me two days

sajidhashmi commented 1 month ago

any solution?

SethCram commented 2 days ago

@sajidhashmi nope, not that I know of. I'm considering just setting the initial route to the tab with the game in it, then navigating away so it atleast starts loading