juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.13k stars 518 forks source link

Does UnityWidget supports restart? #829

Open Raonshi opened 1 year ago

Raonshi commented 1 year ago

Hi. I'm just making flutter application which supports unity.

My flutter project has two Scaffold widget.

In this case, When I click the button in Main Screen, Unity Screen represents UnityWidget well. But, when i click the button in Main Screen after go back to MainScreen from Unity Screen, UnityWidget was not restarted.

I tried use UnityWidgetController.unload(), UnityWidgetController.quit(). But these functions were not solution.

Is there solution for restart UnityPlayer?

Henrik84 commented 1 year ago

It looks like that there is only for the web version a kind of restart//reload of the player. Therefore you have to disable the cache in the Playersettings. I m currently facing the same problem. The unitycontroller is gone when you toggle from and to the unity widget again. Therefore you need a singleton instance of the unitycontroller but this is not possible at the moment. There is a pull request here which will fix it but looks not completed yet :(