Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Captain_Pineapple · Sep 22, 2021 at 10:05 AM · inputbugmousebug-perhapsmouseclick

Unity sometimes misses Mouse Button Release

currently running into a weird issue. Imagine you have this code:

 private bool Mouse0Pressed = false;
 public void Update()
 {
     if(Input.GetMouseButtonDown(0))
     {
         Mouse0Pressed = true;
     }
     if(Input.GetMouseButtonUp(0))
     {
         Mouse0Pressed = false;
     }
 }


In some random situations ( 1 out of ~100) Mouse0Pressed stays true after i release the mouse button. Interesting enough Input.GetMouseButton(0) also returns true in that case which implies to me that Unity missed the MouseButtonUp event. Both states reset to the correct value if i do another click but stay true until then.

Does anyone know if this is a known issue? could not find any info on that. Kind of lost in that regard.

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 Vivien_Lynn · Sep 22, 2021 at 11:36 AM

My first instinct would be to monitor your mouse with some third party sofware, to see if it might be an hardware issue.

Edit, the following is apparently wrong. Read @rage_co o comment below for more information:

This is just an assumption, but I think Unity actually checks if your mouse is pressed or not. If it was pressed, and is not anymore, then Unity calls the "MouseUP once.

This means, even if Unity would "miss" the MouseUP in one particular frame, it does not matter, since it would just check again in the next frame.

If this is true, then it must be your mouse that still sends the input.

Comment
Add comment · Show 3 · 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 rage_co · Sep 22, 2021 at 11:54 AM 0
Share

its actually the opposite, unity and many other engines check for inputs through the down actions and up actions, which means that the computer has no way to know if the button is currently pressed......you can do this experiment, hold down a key in your project or a game and disable the keyboard, the input would still be considered as pressed, until you turn your keyboard back on and repress the button and then let it go.....can also be tried with a mouse, so it can be a hardware problem, about the mouse forgetting to send the up signal

avatar image Captain_Pineapple · Sep 22, 2021 at 12:36 PM 1
Share

it is not a hardware issue as this behaviour is reproduceable on different PCs and i highly doubt that all of them have issues with their mouses.

avatar image rage_co Captain_Pineapple · Sep 24, 2021 at 01:16 PM 0
Share

so is this code all of it? i mean i tried it and it works a 100% fine

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

183 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 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 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 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 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 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 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 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 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 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

When holding down shift cant use the "a" key, an extremely weird bug! 2 Answers

Detect mouse clicks anywhere on the screen except given gameobject 2 Answers

Unity 4.6.3f1 bug or normal behaviour? MouseButtonDown cancelled/ ignored by key press 0 Answers

Disable mouse input and cursor in game 2 Answers

Unity Web Player does not respond to mouse clicks 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