i am making a phone game, and the game is split in 2 parts:

  • the menus
  • the actual game

of course, i want to hide Android's Status Bar and Navigation Bar during the actual game,
but show them during the menus.

how can i toggle the system bars in GDScript? i have no idea where to look for the answer.

The setting to hide the system bar is called immersive mode in the Android export settings. As far as I know, it's not a setting that can be toggled in real time. But I wonder why you would want to show the status bar on menus.

    cybereality i want to show the system bars on menus because not doing so would be a misuse of immersive mode:

    excerpt from Hide system bars for immersive mode – Android Developers

    Be mindful of how often users jump in and out of apps to check notifications, conduct impromptu searches, or other actions. Because using immersive causes users to lose easy access to system navigation, use immersive mode only when the benefit to the user experience goes beyond simply receiving a little extra space (such as to avoid accidental exits during a game or delivering a valuable immersive experience for images, videos, and books).

    during the actual game, immersive mode brings the extra benefits:

    • avoid accidental exits during a game
    • delivering a valuable immersive experience for video(game)s

    but in the menus, immersive mode doesn't bring these benefits:
    in the level select or pause menu, players might want to check notifications, conduct impromptu searches, or other actions.

    this is why showing the system bars during the game but not in the menus makes my app much friendlier to use, which is why i want to do it.

    If it's a game, then users will expect it to be full screen, as this is how almost all games work on mobile.

      cybereality I agree with your reply. But could the OP's request be implemented using a custom Android export template?

      Perhaps, but it would be a lot of work for an arguably worse user experience.

      That's true, but knowing how to do it could be useful for similar situations.

      I don't think an export template would help. The link to "hide the system bars" shows the system calls to toggle them, and I doubt that godot has any way to do that since it's an android-only function that most people aren't especially interested in. You'd have to build an android plug-in.

      a year later

      i made a 'Toggle system bars' button with this script:

      extends Button
      
      
      var show_system_bars: bool = true
      
      
      func _pressed() -> void:
      	show_system_bars = not show_system_bars
      	if show_system_bars:
      		print_debug('show system bars')
      	else:
      		print_debug('hide system bars')

      i want to change the print_debug messages to actually showing and hiding the system bars (status bar and navigaion bar) on Android. i need concrete steps on how to do this.

      in my minimal reproduction project (attachment, 5.8 MiB unzipped), the button script belongs to the child of res://main.tscn root.

      android-toggle-system-bars.zip
      749kB