[Android] toggle System Bars?
Asked Answered
S

8

0

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.

Saar answered 13/7, 2022 at 8:56 Comment(0)
J
0

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.

Jacindajacinta answered 13/7, 2022 at 10:10 Comment(0)
S
0

Jacindajacinta 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.

Saar answered 13/7, 2022 at 10:32 Comment(0)
J
0

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

Jacindajacinta answered 13/7, 2022 at 15:41 Comment(0)
D
0

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

Daughterly answered 13/7, 2022 at 15:56 Comment(0)
J
0

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

Jacindajacinta answered 13/7, 2022 at 17:12 Comment(0)
D
0

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

Daughterly answered 14/7, 2022 at 1:31 Comment(0)
E
0

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.

Eshman answered 14/7, 2022 at 1:46 Comment(0)
S
0

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
Saar answered 18/8, 2023 at 15:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.