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!

Application.platform, or probably better, conditional compilation (i.e., “#if UNITY_IPHONE” etc.).

Take a look at the reference for Application.platform.