Hi.
I’m working on a web browser game and I need to make mobile controls that appear only if the game’s being played on a mobile device.
I have no idea on how that could be done honestly.
My only idea would be checking window / screen size somehow but is that even possible in godot?
Oops sorry,I thought you are taking about responsive ui,and yeah you can’t see the os in web export version! You should check for the screen size!
Here’s a demo:
func _ready():
var size = OS.get_screen_size()
var min_side = min(size.x, size.y)
print("Screen size:", size, " | Shortest side:", min_side)
if min_side < 1280:
print("Likely a phone/tablet")
else:
print("Likely a desktop/laptop")
You can check different sizes or just ask the player that is it on a desktop or phone!
Thanks for the confirmation and for the script, this really makes things easier, I used to make a copy of every project just to add the extra controls, it was a pain lol.