- Home /
OnMouseUP sometimes doesn't work
Hi All.
Just wondering if anyone else has experienced this before. I have a simple script that uses function OnMouseUp() to instantiate a menu, however I have noticed sometimes it doesn't work depending on how much stuff is going on on screen.
Has this this happended to you? Did you fix it?
Thanks
Steve
Answer by fafase · Apr 10, 2013 at 07:42 PM
You would not have it in the FixedUpdate?
If so, you need to place it in the Update.
Ah, I have been using it as another function, do you mean I should use "if(Input.Get$$anonymous$$ouseUp)?
Oops not, my bad, I thought of Get$$anonymous$$ouseButtonUp. I'm out...
Can someone please clarify this? I am having the same issue, but @fafase answer is not making sense.
This is not even a comment. I guess I left it so that the user could see that the answer was wrong but it should be removed.
Concerning the content of it, as mentioned in a comment, I thought it was using Get$$anonymous$$ouseButtonUp which would fail in the FixedUpdate and should be moved to Update to make sure all calls are successful.
For a more detailed comment, On$$anonymous$$ouseXXX only works with 3D collider so it could be a guess if one is trying to use it on 2D sprite. Also, I have experienced buggy behaviour of that event and favored a basic raycast system ins$$anonymous$$d.
Answer by JtheSpaceC · May 22, 2015 at 07:37 PM
You'd mostly be checking for the input in one of your Update functions.
void Update()
{
if (Input.GetMouseButtonUp (0))
{
//do something
}
}
If you're in update then you're checking every frame and shouldn't miss any input ticks. If the above function were within FixedUpdate() then you're checking at regular timed intervals and might miss the Down or Up parts of checks.
It is a On$$anonymous$$ouseXXX event method so it is not related to the Update/FixedUpdate.
Your answer
Follow this Question
Related Questions
Animate Button/Object When Clicked In Game 2 Answers
OnMouseUp and GUITexture 1 Answer
OnMouseUp not working in build? 0 Answers
OnMouseDown 2 Answers
On Mouse Up On Multiple GUI Texts 0 Answers