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.14k stars 522 forks source link

Question: is unity running in the background all the time? #508

Closed omgmax closed 2 years ago

omgmax commented 2 years ago

Just wondering if unity is running in the background all the time with this implementation.

OGmetamonkey commented 2 years ago

I believe after Unity launches for the first time it will continue running for the entire app session. You can minimize the impact of this by switching to an empty scene when you don't need Unity running.

MysteryKang commented 2 years ago

there is a dispose function in flutter, when screen is off from the tree in this case unity also will be disposed as well. in other scenario you can also set PlayerLoop.setPlayerLoop to false, then it'll shut down unity entire loop to save energy, and when you want to run unity again you can just turn it back on.

AkhilRaja commented 2 years ago

@MysteryKang can you please provide some more details on how to do that ? I'm facing a lot of issues when trying to unload/dispose. A lot of crashes and freezes.

juicycleff commented 2 years ago

@AkhilRaja you do that in unity just fire an event from a flutter to tell unity to go into this mode https://docs.unity3d.com/ScriptReference/LowLevel.PlayerLoop.SetPlayerLoop.html and yes Unity always runs in the background after the first launch.