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 /
  • Help Room /
avatar image
1
Question by unknownUser1919 · Jan 04, 2021 at 08:30 PM · scrollwheel

Is there another way to detect mouse scroll in game for macOS?

Hello, I was trying to use Input.mouseScrollDelta to check if a user scrolled up, down, left or right to check the direction of a gesture on both the Magic Mouse and macOS track pad. Everything seemed to work fine, however, it seems as if the Input.mouseScrollDelta is not designed to work with such devices. The main problem I am facing is that the Input.mouseScrollDelta works by PC mouse scroll wheel clicks, one click equals one input. Every swipe on the Mac counts as many as 8 to 200 scroll wheel clicks for the equivalent PC mouse scroll wheel. The only way to stop this from happening is to let the scroll fully stop registering as input and then re-enable to capture more inputs. The problem is that I need the input to be very quick so that it can capture more directional swipe inputs. Currently it takes a full 2 seconds to stop registering input, even from a very light scroll. This won't work for what I am trying to achieve and I was wondering if there is any other way to go about this problem. I have also tried to adjust the values in the if statements, however, this still does not fix the problem. Thank you for your time.

 // block the input from getting called multiple times, re-enable after Vector2.zero
     private bool isReset = true;
     
     public void OnGUI()
     {
         MouseInputMethod();
     }
     void MouseInputMethod()
     {
         if (isReset == true)
         {
             if (Input.mouseScrollDelta.y > 1f)
             {
                 Debug.Log($"DOWN");
                 isReset = false;
                 StartCoroutine(ResetZero());
             }
 
             if (Input.mouseScrollDelta.y < -1f)
             {
                 Debug.Log($"UP");
                 isReset = false;
                 StartCoroutine(ResetZero());
             }
             if (Input.mouseScrollDelta.x > 1)
             {
                 //Debug.Log($"RIGHT");
                 isReset = false;
                 StartCoroutine(ResetZero());
             }
 
             if (Input.mouseScrollDelta.x < -1f)
             {
                 //Debug.Log($"LEFT");
                 isReset = false;
                 StartCoroutine(ResetZero());
                 
             }
         }
     }
     IEnumerator ResetZero()
     {
         // wait until the vectors have returned to 0
         while (Input.mouseScrollDelta != Vector2.zero)
         {
             // wait a frame to make sure that the input is the final scoll click
             yield return new WaitForEndOfFrame();
             // check to see if this is the final scroll click
             if (Input.mouseScrollDelta == Vector2.zero)
             {
                 // wait one more frame
                 yield return new WaitForEndOfFrame();
                 // check once more to make sure that this is the final scroll click
                 if (Input.mouseScrollDelta == Vector2.zero)
                 {
                     // reset the isReset to true so the input can continue to be read
                     isReset = true;
                     // break out
                     break;
                 }
                 else
                 {
                     // if there is more clicks left continue the while statement
                      continue;
                 }
             }
         }
     }

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 egeunlu · Jan 06, 2021 at 03:35 AM

I have the same problem with WebGL unity, there are two suspicious properties in standalone input module, 'input actions per second' and 'repeat delay', I have increased the first field up to 1000 but no changes so far.

Comment
Add comment · Show 5 · 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 unknownUser1919 · Jan 06, 2021 at 04:01 AM 0
Share

What are you specifically trying to do? Just capture Directional swipe movements?

avatar image egeunlu unknownUser1919 · Jan 06, 2021 at 04:40 AM 0
Share

Yeah, horizontals for movement and verticals for a custom scrollview.

avatar image unknownUser1919 egeunlu · Jan 06, 2021 at 05:57 AM 0
Share

If you are doing a scroll view try this?

     public float yVector = 0;
     public float xVector = 0;
     public float distance$$anonymous$$ultiplier = 1f;
     void Update()
     {
         if (Input.mouseScrollDelta != Vector2.zero)
         {
             if (Input.mouseScrollDelta.y > .01f)
             {
                 yVector += 1f  * distance$$anonymous$$ultiplier;
                 Debug.Log($"SWIPE DOWN : {yVector}");
             }
             if (Input.mouseScrollDelta.y < -.01f)
             {
                 yVector -= 1f  * distance$$anonymous$$ultiplier;
                 Debug.Log($"SWIPE UP : {yVector}");
             }
             if (Input.mouseScrollDelta.x > .01f)
             {
                 xVector += 1f  * distance$$anonymous$$ultiplier;
                 Debug.Log($"SWIPE RIGHT : {xVector}");
             }
             if (Input.mouseScrollDelta.x < -.01f)
             {
                 xVector -= 1f  * distance$$anonymous$$ultiplier;
                 Debug.Log($"SWIPE LEFT : {xVector}");
             }
         }
     }
Show more comments

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

155 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

Related Questions

Java to C# Translation 1 Answer

Dropdown list scrollwheel - Camera zoom scrollwheel how can separate? 0 Answers

Input.GetKey Shift Key disbles GetAxis Mouse ScrollWheel? 1 Answer

Why is laptop Touchpad two finger scolling not working on scrollrect in unity game? 0 Answers

input.getkey keycode scrollwheel - Is this even possible? 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