简体   繁体   中英

Unity: Hide Navigation Bar

How do I hide only the navigation bar in an Android app made in Unity?

I've already tried Screen.fullScreen = false, but that shows both the status bar and the navigation bar over the content.

// Resume Unity
@Override
protected void onResume() {
    super.onResume();
    mUnityPlayer.resume();
    mUnityPlayer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}

This will hide the navigation panel even if you disable full screen mode in Unity Editor.

There is an asset on Unity store that will help you get what you want. Android Immersive Mode

With Unity 2019.2 you can change that option in Player settings

  1. Press "Ctrl + Shift + b" to open Build settings

  2. Click on "Player settings ..." button to open Player setting panel.

  3. Select Tab "Player".

  4. And turn on "Start in fullscreen mode".

检查这张图片

I ended up using the script posted in the link below. http://zehfernando.com/2015/unity-tidbits-changing-the-visibility-of-androids-navigation-and-status-bars-and-implementing-immersive-mode/

When implementing this script to your Unity project, you can then use the following code to show both the navigation bar and the status bar. If you only want to show the status bar, and not the navigation bar, set the navigation bar state på .hidden!

ImmersiveAndroid.statusBarState = ImmersiveAndroid.States.Visible; ImmersiveAndroid.navigationBarState = ImmersiveAndroid.States.Visible;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM