- Home /
Detect if running on mobile vs desktop
I have multiple code pieces that I want to handle differently if my game is running on a mobile device rather than a desktop. Namely:
Control scheme (touch vs keyboard & mouse) (Note that this also alters the on-screen hud visuals)
LOD
Resolution / aspect ratio for visual elements
Is there a way to detect if the game is running on mobile vs a desktop? Or is there at least a way to detect if a keyboard & mouse are present?
(I'm using JavaScript)
Thanks!
Answer by Eric5h5 · Apr 11, 2012 at 06:34 PM
Application.platform, or probably better, conditional compilation (i.e., "#if UNITY_IPHONE" etc.).
Link in the answer is broken. Somebody please fix it.
Conditional compilation was what solved it for me. The proper link for that is now Platform Dependent Compilation. Also, if this question was useful for you, please consider giving it a thumbs up ;)