Topic was automatically imported from the old Question2Answer platform.
Asked By
duke_meister
Old Version
Published before Godot 3 was released.
I thought there would be something in the OS class for this, but what’s a good way of determining whether you’re running on a mobile device vs desktop?
OS.get_name() gives you the name of the operating system, on Windows it returns Windows. However it’s not handy to test if we are on a mobile device or not, so I’m curious to see if there is a better approach too.
Zylann | 2016-05-25 23:41
Thanks, somehow I missed that but I remember seeing it before. For my needs now this will be ok.
So you have to test if the name corresponds to a mobile platform.
I’m curious to see if there is a better approach too.
Thanks. I’ll wait a while but no doubt this will be the best answer. I guess it’s easy enough to make a global func is_on_mobile() and just check for Android, iOS etc but something in OS would be ‘nice’.
For mobile vs desktop, Zylann’s answer is likely the most straightforward solution.
If your concern is to know whether controls should be touch-based or mouse and keyboard, you can also use OS.has_touchscreen_ui_hint(), which might (I haven’t tested it) work too for touch-based desktop platforms (e.g. a Linux tablet, or the Windows Surface thingy).
Thanks for the extra info, I was wondering about that function.