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
1
Question by sarysa · Apr 17, 2012 at 01:47 AM · inputmissingscrollingmacosxgestures

Horizontal Scrolling on a Trackpad (MacOS X)

I need to be able to detect horizontal scrolling on trackpads on MacOS. Input.getAxis("Mouse ScrollWheel") detects the vertical axis, but there's nothing built in (that I'm aware of) for the horizontal axis.

I created a plugin that attached an NSResponder to the main window and listened to some trackpad events. swipeWithEvent is the one I care most about, but I also detected magnifyWithEvent and rotateWithEvent for the fun of it. I attached it with this code:
[[[NSApplication sharedApplication] mainWindow] setNextResponder:obj]

That worked, but only for the magnify and rotate events. It still can't detect the swipes. I think the problem is that my object is lower on the responder chain and Unity needs to listen to swipeWithEvent for the "Mouse ScrollWheel" axis. So I tried this code after the previous line:
[[[NSApplication sharedApplication] mainWindow] makeFirstResponder:obj]

That didn't change anything. Unity still gets swipes first, and it's tossing out the horizontal axis scrolling as far as I know.
Is there anything I can do? I'd be perfectly okay with a solution where my plugin ends up taking over both axes and I have to rewrite the code that uses Input.getAxis("Mouse ScrollWheel")

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by sarysa · Jun 22, 2012 at 09:44 PM

Self-answer. Doesn't look like there's a way to just poll it at any time. All calls to OnGUI() need to be checked and code like this needs to be implemented:

     Event ev = Event.current;
     if (ev.type == EventType.ScrollWheel)
     {
         someX = ev.delta.x;
         someY = ev.delta.y;
     }
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
avatar image
1

Answer by greay · Mar 31, 2018 at 12:54 AM

This is ages late, but it's worth pointing out at least with Unity 5.6.4, it's possible to get it from Input.mouseScrollDelta – which looks to work anywhere you'd use Input.GetAxis(). The scale is different, however: on initial glance, it's a flat 10x.

Comment
Add comment · Show 1 · 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 kiwi137414 · Jun 12, 2018 at 06:20 PM 0
Share

Thanks a lot, this worked for me.

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

6 People are following this question.

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

Related Questions

unity 4.6 input, missing touches 0 Answers

How to detect if an object is being moved back and forth by the user? 0 Answers

Why are these missing assembly references by working on the game "Astro Dude?" 0 Answers

My Mouse ScrollWheel input is missing! 1 Answer

How to trigger sound only when both fingers lifted off 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