Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by And0 · Jan 14, 2014 at 10:16 PM · onmouseupmouse drag

OnMouseUp() doesn't behave as documented

I know that this question has been asked before (for example here) but I didn't find a satisfactory answer; also, the answers provided in those threads used an older version of the documentation which has now changed.

Now to the issue at hand. Here's a quote from the MonoBehaviour:OnMouseUp() documentation:

Note that OnMouseUp is called even if the mouse is not over the same GUIElement or Collider as the has[sic] mouse has been pressed down on.

I find that this is not true. When I press the mouse button down next to my object with the OnMouseUp() script attached, then drag it in and release the button, nothing fires. Same thing when I drag from one object to another. In short, OnMouseUp() seems to behave the same way as OnMouseUpAsButton().

I checked the Issue Tracker but didn't find anything. Am I doing something wrong, is this a bug? Or is the documentation just wrong?

Comment
Add comment · Show 2
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 Eric5h5 · Jan 14, 2014 at 10:27 PM 1
Share

Definitely works as documented here. When you say "I press the mouse button down next to my object" it sounds like you're not actually clicking on the object. You have to click on the collider itself, not somewhere next to it.

avatar image And0 · Jan 14, 2014 at 11:34 PM 0
Share

Then let's put it another way. Let's say I have two objects, A and B. Object B has a script attached that contains On$$anonymous$$ouseUp(){...}. I move the cursor into object A, press and hold down the mouse button. Then I drag the cursor into Object B and release the mouse button; I would expect On$$anonymous$$ouseUp() to fire, as the mouse button went up while hovering over Object B, but it doesn't...so something is wrong here, even if it's just my understanding of the documentation.

EDIT: Argh, never$$anonymous$$d...it really was a misunderstanding. Thanks for the response and sorry for the confusion!

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by And0 · Jan 14, 2014 at 11:55 PM

Nevermind, I think it was really just a misunderstanding on my part. What the documentation means is that OnMouseUp() will still be fired even if the cursor has been moved outside of the original collider where the mouse button was pressed. So:

Click on Object A that has OnMouseUp script attached -> move cursor outside -> let go of button -> OnMouseUp() of Object A will still be called

I understood it as "when you let go of the button, the OnMouseUp() of the object that is currently under the cursor will be called", so:

Press and hold the mousebutton down on some random object -> move cursor over object B that has OnMouseUp attached -> let go of button -> OnMouseUp of object B will be called

Sorry about the confusion, guess I was just too tired.

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

19 People are following this question.

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

Related Questions

Anyone have a double-click script more reliable than mine? 3 Answers

OnMouseUP sometimes doesn't work 1 Answer

How can I trigger GetMouseButtonUp when the cursor leaves the game window? Or if the window is minimised, etc? 2 Answers

C# MOUSE EVENT TOGGLE 1 Answer

mouseup event does not work soon 0 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