react-native-unity icon indicating copy to clipboard operation
react-native-unity copied to clipboard

Unity doesn't load after reloading in metro bundler (Android)

Open carlandren2002 opened this issue 1 year ago • 2 comments

Unity loads perfectly and works each time I run "npm run android" but if I reload the app by pressing R in the metro bundler, I can't get the UnityView to load anymore.

Is there any way to fix this? Will it be a problem in the final version of the app?

carlandren2002 avatar Aug 10 '24 15:08 carlandren2002

The lifecycle methods aren't reliably called on fast refresh. Try adding this to the top of your unity file:

// https://reactnative.dev/docs/fast-refresh#fast-refresh-and-hooks
// @refresh reset

markrickert avatar Sep 10 '24 13:09 markrickert

Unfortunately it still freezes whenever a fast refresh is performed (only if the Unity view is visible). But I take it as if this isn't a problem in production since it's specifically during a fast refresh this happens?

carlandren2002 avatar Sep 30 '24 19:09 carlandren2002