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 /
  • Help Room /
avatar image
0
Question by Simoneon · Apr 06, 2018 at 09:04 PM · osxtouchpadinconsistentgetmousebutton

Problem with Input.GetMouseButtonUp(0) and Macbook Pro touchpad.,Problem with Input.GetMouseButtonUp(0) on Macbook touchpad

Hello,

I have searched the net but could not find a similar problem so I am hoping there are improvement I could add to the code to fix this problem.

My problem is that the left click when tapping lightly on the touchpad lacks consistency when returning true from the Input.GetMouseButtonUp(0). It usually takes couple of taps for it to return true and select my unit. However when actually clicking and not tapping either with touchpad or mouse it works 100% of the time. I am wondering where this kind of inconsistency would come from. I'd be happy to know your ideas! The code in C# can be seen in FIG 1.

Couple of points: - I am not using FixedUpdate, everything is happening in Update. Otherwise regular clicking would have problems as well I'd imagine. - I cannot use GetMouseButtonDown or GetMouseButton because they are reserved for dragging the camera. I don't want units deselecting when dragging the camera! - Not sure why, but switching the execution order of the elseif-chain and adding additional bool which does not let GetMouseButtonDown activate if camera is dragging did not fix it (FIG 2). Thus I feel like the inconsistent connection between tapping on the touchpad and triggering GetMouseButtonUp might be internal.

FIG 1:

     void Update () {
 
         if (Input.GetMouseButtonDown (0)) {
             // Left mouse button just went down. This doesn't do anything yet.
 
         }
         else if (Input.GetMouseButtonUp (0)) {
 
             // If we are clicking a tile with a unit, select it.
             if (tileUnderMouse.unit != null) {
                 selectedUnit = tileUnderMouse.unit;                    
                 cbUnitSelected (selectedUnit);
             }
 
             // Else deselect anything that was selected.
             else {
                 selectedUnit = null;
                 cbUnitSelected (selectedUnit);
             }
         }
         else if (Input.GetMouseButton (0) && 
             Vector3.Distance (currFrameMousePosition, lastFrameMousePosition) > mouseDragThreshold) {
 
             // Left button is held down and the mouse moved an appropriate amount: start camera drag.
             Update_CameraDrag ();
         }
     }



FIG 2: void Update () {

         if (Input.GetMouseButton (0) && 
             Vector3.Distance (currFrameMousePosition, lastFrameMousePosition) > mouseDragThreshold) {
 
             // Left button is held down and the mouse moved an appropriate amount: start camera drag.
             isDragging = true;
             UpdateCameraDrag ();
         }
         else if (Input.GetMouseButtonDown (0)) {
             if (isDragging == true) {
                 return;
             }
 
             // If we are clicking a tile with a unit, select it.
             if (tileUnderMouse.unit != null) {
                 selectedUnit = tileUnderMouse.unit;                    
                 cbUnitSelected (selectedUnit);
             }
 
             // Else deselect anything that was selected.
             else {
                 selectedUnit = null;
                 cbUnitSelected (selectedUnit);
             }
         }
     }



Thank you very much for your time!

Simon

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.

Follow this Question

Answers Answers and Comments

130 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

Related Questions

Monodevelop 4.0.1 strange font on Mac El Capitan 0 Answers

Could I access to finder osx label color ? 0 Answers

Calling functions from Native DLL (C++) inconsistently crashes Unity 1 Answer

Unity on Mac get Error 500 while trying to activate Personal Edition license 1 Answer

Android Touchpad - Registering touch on whole screen 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