Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by NateJC · Apr 11, 2012 at 06:29 PM · inputmobiledetectionuniversaldesktop

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!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
12
Best Answer

Answer by Eric5h5 · Apr 11, 2012 at 06:34 PM

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

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NateJC · Apr 11, 2012 at 06:47 PM 0
Share

Awesome! That was just the pointer I needed. Thanks!

avatar image AkooleGame · Jan 29, 2015 at 10:23 AM 0
Share

Link in the answer is broken. Somebody please fix it.

Application.platform

avatar image NateJC · Jan 29, 2015 at 05:27 PM 3
Share

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 ;)

avatar image azevedco · Sep 01, 2021 at 07:16 PM 1
Share

Probably the new link: Platform Dependent Compilation

avatar image
2

Answer by efge · Apr 11, 2012 at 06:33 PM

Take a look at the reference for Application.platform.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mgear · May 04, 2016 at 07:34 AM 0
Share

new link: http://docs.unity3d.com/ScriptReference/Application-platform.html

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to standardize player input for AddForce on mouse/finger cursor 0 Answers

Input.GetKeyDown doesn't work with several keys 1 Answer

Mobile Face Detection 1 Answer

How do i properly use Application.platform ? 1 Answer

How can i get OnPointerExit to work on mobile? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges