• 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
1
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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

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

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

Input does not seem to recognize + and - keystrokes 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges