flutter-unity-view-widget icon indicating copy to clipboard operation
flutter-unity-view-widget copied to clipboard

quit and unload methods not Implemented

Open codesculpture opened this issue 1 year ago • 8 comments

If i try to invoke unityWidgetController.quit() or unityWidgetController.unload() am getting Missing Implementation Error

codesculpture avatar Aug 09 '23 16:08 codesculpture

Which platform is this (ios, android, web)? And how/where are you calling these functions?

Quit is useless as it kills your entire app, but i've used unload plenty of times.

timbotimbo avatar Aug 09 '23 17:08 timbotimbo

Iam trying this on Android, and am calling the unityController.unload() at app's dispose (stateful widget) method. I can see that game is never closes like once i opened the game and no matter how many time i pop this page and come again and the game still in the same state where i last time leaves on pop Method

codesculpture avatar Aug 09 '23 17:08 codesculpture

Also when i open the game it would make disappear the android's navigation bar and status bar and it not restored when the game end, can anyone help this.. i tried many ways but none of em working

codesculpture avatar Aug 09 '23 18:08 codesculpture

Iam trying this on Android, and am calling the unityController.unload() at app's dispose (stateful widget) method. I can see that game is never closes like once i opened the game and no matter how many time i pop this page and come again and the game still in the same state where i last time leaves on pop Method

I think this error might come from using the unitycontroller when the widget has already been disposed. Can you try calling unload before popping. Either do it before Navigator.of(context).pop, or in a WillPopScope.

Also when i open the game it would make disappear the android's navigation bar and status bar and it not restored when the game end, can anyone help this.. i tried many ways but none of em working

Once Unity goes fullscreen, flutter can't seem to revert that on android. You can do this by calling a Unity function from flutter, that makes Unity disable fullscreen.

    public void DisableFullscreen(string str = "")
    {
#if UNITY_ANDROID
        Screen.fullScreen = false;
#endif
    }

timbotimbo avatar Aug 09 '23 18:08 timbotimbo

Hey also, i passed unLoadonDispose to be true on UnityWidget, but i dont think it is working either. I needed that game is to be totally closed when the page is closed from flutter. And the game should reload again after when i opened the game page... But it seems the game is being always loaded.. like if i open the game page for first time it would take some time to load and shows the game . But after i close the game page and repopen the game page the game is already in the same state where i lastly visited the game page. I dont want this behavior

codesculpture avatar Aug 09 '23 18:08 codesculpture

I am impacted too on iOS. Calling unload in a dispose method does not unload unity at all. It was working fine in 2020.3.25 unloadOnDispose does not work neither.

alexandrefresnais avatar Sep 27 '23 17:09 alexandrefresnais

Same here as well. Tried only iOS. Using version 2022.2.0 and Unity 2022.3.34. Tried manual unload and unloadOnDispose and didn't work.

konsnos avatar Aug 08 '24 14:08 konsnos

Bumping up this thread, i literally dint touched flutter (and unity) almost a year. But happy to help. I think we should not call quit as @timbotimbo said since it would just kill the process (where our flutter app also lives in the same process, hence it will also get closed)

https://discussions.unity.com/t/integration-unity-as-a-library-in-native-android-app/744894/5

Someone here explained what i want to just convey, the implementation of quit on UnityPlayer in unity-classes.jar which eventually kill the process. We dont need that, we just need to destroy the unity activity and its memory. I think in the discussion someone mentioned "we are working on it"

Hope for good 🤞

codesculpture avatar Aug 14 '24 06:08 codesculpture