Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 /
  • Help Room /
avatar image
1
Question by Beeblebrox · Jul 15, 2015 at 07:38 PM · buildtranslate

Input.GetMouseButtonDown() translates automatically to Mobile Platforms?

Say I wrote a mouse-only game for PC, using Input.GetMouseButtonDown(0) and functions like those. Will these functions work also on Mobile touchscreen devices like Android or iOS, and translate automatically to the finger taps?

In other words, do I need to edit my project or will Unity do these translations automatically for me?

The reason I ask is when I run the Android emulator with my project, as soon as I trigger an event which is mouse-press, the emulator crashes.

Thank you!

Comment
Add comment · Show 1
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 Owen-Reynolds · Jul 15, 2015 at 08:53 PM 0
Share

Yes, Unity can use most PC input commands on a touchscreen. It's a feature Unity3D added to those commands. Search "unity onmousedown touchscreen" for details.

But tanoshimi isn't wrong. Anything but the most simple input system should probably be rewritten using the touchPad input commands.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by pedrampk · Jul 15, 2018 at 04:03 PM

Input.GetMouseButtonDown(0) will be translate to single tap automatically. and the Input.mousePosition is translated to the position of tapped point.

Comment
Add comment · 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
1

Answer by tanoshimi · Jul 15, 2015 at 07:48 PM

Android devices, in the main, don't have mouse input. But some do. PCs, in the main, don't have touch input. But some do.

My point is that the way in which you handle mouse/touch input is independent of your target platform, and Unity can't guess what input system you want.

Secondly, touch/mouse are really very different anyway, and should be designed specifically to account for their own unique affordances: What would be the touch equivalent of a right click? What would be the mouse equivalent of a pinch gesture? Precise double-tapping is much harder than precise double-clicking, but swiping with a finger is easier than swiping with a mouse.

Input.touches gives you all you need to design touch interfaces, and you can use preprocessor directives to switch input schemes depending on platform as you choose.

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 Beeblebrox · Jul 15, 2015 at 07:56 PM 0
Share

I guess I will have to rework my project for touch interface. Thank you for the quick help!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

After build doesnt work 0 Answers

Build EXE - Crashes 0 Answers

Lightmapping stuck at 3/15 baking resources 1 jobs 1 Answer

i5 or i7 for Unity Projects? 2 Answers

Textures from local works in editor missing in build 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