Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by jasbro · Aug 04, 2016 at 10:13 AM · inputmouseinputmanagerscripting-underthehood

Object.OnMouseDown vs Input.GetMouseButtonDown

This question applies to all of the OnMouseXXX and GetMouseButtonXXX and GetButtonXXX methods.

Can someone please explain the details under the hood and when should I chose one approach vs the other?

I'm seeing slight gotchas that I don't understand. Such as, according to the Execution Order, the OnMouseXXX events occur before Update. Cool, but it doesn't work on Right Click Mouse events and there doesn't appear to be a way for me to extend that functionality. So this forces me to handle right click events differently from left click events. Another oddity, the use of GetButtonXXX. It uses the Input Manager, so I can call GetButtonXXX("Fire2") to capture a mouse right click. That's cool, but what's up with GetMouseButtonXXX(1)? I thought maybe it was the mouse version of the GetKeyXXX, but KeyCode enum has mouse button enumeration.

I'm very confused. Between all of the different ways to handle input, I'm beginning to think that I need to abstract my own input class so it can cleanly handle all mouse events. But that feels wrong. Any advice appreciated.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by awghulam555 · Jun 01, 2020 at 01:29 AM

I think OnMouseDown is for Rigid bodies and GetMouseButtonDown is used as a universal input. I am NOT saying that this may be correct. It may be wrong. This is just my guess, but I do know that they are basically the same thing. If one dosen't works, try the other. But both have a specific logic. I think that you'll be mostly fine with OnMouseDown

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Players on one Computer/Console 5 Answers

Touch inputs on a Desktop type device 2 Answers

What's the entry name for mouse buttons in InputManager? 2 Answers

GetAxisRaw("Mouse X") not even close to manual mouse movement 0 Answers

Mouse Input Lag 3 Answers


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