Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android]: Fullscreen issue #550

Closed
al-virti opened this issue Mar 14, 2022 · 5 comments
Closed

[Android]: Fullscreen issue #550

al-virti opened this issue Mar 14, 2022 · 5 comments

Comments

@al-virti
Copy link

al-virti commented Mar 14, 2022

Describe the bug
For some reason, the navigation bar isn't hiding on Android when setting "fullscreen" boolean to true, I have "Fullscreen" unchecked in the Unity project. Additionally, the status bar doesn't restore once the Unity Player goes out of view. I even tried using unload() and pause().

To Reproduce
Steps to reproduce the behavior:

  1. Load UnityWidget with fullscreen: true

Expected behavior
The system bars should hide when UnityWidget is built with fullscreen flag.

Screenshots
If applicable, add screenshots to help explain your problem.

OP 7 Pro Android 10:
https://user-images.githubusercontent.com/101586610/158229421-1cc08ac8-e025-4f35-a021-8192aef67def.mp4

Xperia 10 iii Android 11:
https://user-images.githubusercontent.com/101586610/158229557-26a7f904-22d3-4c7d-945b-9fdfab7694a9.mp4

Pixel 4 XL Android 12:
https://user-images.githubusercontent.com/101586610/158229614-dbe1b393-27e3-4b15-98f3-93885ca33fa7.mp4

Unity (please complete the following information):

  • OS: Windows
  • Version 2020.3.5f1

Smartphone (please complete the following information):

  • Device: Google Pixel 4 XL, Sony Xperia 10 iii, OnePlus 7 Pro
  • OS: Android 12, Android 11, Android 10

Additional context
So basically, I have a 360 interactive video player created in Unity that I require in my Flutter project, so I need to hide system bars on demand. It seems like Unity keeps overriding system bar configs as I've also tried using SystemChrome.setEnabledSystemUIMode to change between edgeToEdge and immersive modes to change system bars behaviour.

@al-virti al-virti changed the title [Android [Android]: Fullscreen issue Mar 14, 2022
@droncaglio
Copy link

droncaglio commented Mar 15, 2022

I have the same issue, indeed this is happening " It seems like Unity keeps overriding system bar configs as I've also tried using SystemChrome.setEnabledSystemUIMode to change between edgeToEdge and immersive modes to change system bars behaviour." When using SystemChrome.setEnabledSystemUIMode the navigation bar gets crazy on and off in loop.

I don't want to display fullscreen, but I also don't want de navigation bar active.

I was able to achieve what I want by:

Unity -> Project Setting -> Resolution -> Start in fullscreen mode = true

UnityWidget with both hideStatus and fullscreen set to true;

On my flutter widget parente I also used SystemChrome.setEnabledSystemUIMode

@al-virti
Copy link
Author

I have the same issue, indeed this is happening " It seems like Unity keeps overriding system bar configs as I've also tried using SystemChrome.setEnabledSystemUIMode to change between edgeToEdge and immersive modes to change system bars behaviour." When using SystemChrome.setEnabledSystemUIMode the navigation bar gets crazy on and off in loop.

I don't want to display fullscreen, but I also don't want de navigation bar active.

I was able to achieve what I want by:

Unity -> Project Setting -> Resolution -> Start in fullscreen mode = true

UnityWidget with both hideStatus and fullscreen set to true;

On my flutter widget parente I also used SystemChrome.setEnabledSystemUIMode

Thanks for the suggestion @droncaglio ! This made the system bars to hide altogether, but unfortunately I still have a problem with the second issue, most likely related to Unity overriding SystemChrome settings.

When I go out of the video player, I would like the system bars to restore back to edgeToEdge mode. Unfortunately, the system bars will remain in immersive mode until the app restarts, even after trying to set SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge). I'm not sure if there's any way to stop Unity from overriding the system bars behaviour?

@venkatjg
Copy link

venkatjg commented May 5, 2022

same issue here

@timbotimbo
Copy link
Collaborator

You can actually dynamically change the fullscreen setting in Unity, besides the player settings mentioned above.

 Screen.fullScreen = true; // or false

You could use the player settings toggle to boot in fullscreen and send a message from flutter when leaving the widget, to exit the fullscreen state in Unity.

Heres just a little example using the example app rotation slider. Unity becomes fullscreen if the speed is > 0.
I did not use any fullscreen or hideStatus parameters in the UnityWidget in flutter.

public void SetRotationSpeed(String message)
    {
        float value = float.Parse(message);
        if(value <= 0)
        {
            Screen.fullScreen = false;
        } else
        {
            Screen.fullScreen = true;
        }
        RotateAmount = new Vector3(value, value, value);
    }
Screen_Recording_20220628-130722.mp4

@al-virti
Copy link
Author

al-virti commented Jul 4, 2022

@timbotimbo Thank you very much for the suggestion. Combining your fix with @droncaglio 's suggestion to enable hideStatus and fullscreen flags in the UnityWidget did the trick!

For anyone else out there looking for a fix, here's what I did (At time of writing, I am using 2022.1.1+4 of the flutter_unity_widget and few-2022.1.1-v2.unitypackage imported to a project using 2020.3.5.f1 of the Unity Editor):

  • Set Screen.fullScreen = true just before loading the first scene in Unity
  • Set hideStatus and fullscreen parameters in UnityWidget to true
  • Set Screen.fullScreen = false when exiting Unity (I have Unity send a message to Flutter to exit, which invokes Flutter to use the Navigator to pop out of the unity player widget)
  • Set SystemChrome.setEnabledSystemUIMode to SystemUiMode.edgeToEdge in Flutter upon receiving Unity's message to exit (You may encounter rare occurrences where the system bars aren't restored properly on Android, you can use await Future.delayed for 500ms or so to avoid this.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants