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 /
avatar image
1
Question by ericchen1248 · Feb 07, 2017 at 05:33 PM · bug-perhapsscrollwheel

Input.GetAxis("Mouse ScrollWheel") not working without wheel being clicked in

So, is there anyone else with this problem? I currently have var num = Input.GetAxis("Mouse ScrollWheel") Camera.main.orthographicSize -= num; Debug.Log(num);

Debug shows a constant zero when I scroll, only outputting non-zeros if I click in the scrollwheel and scroll at the same time.

Occurs on Logitech M215 Unifying mouse, M557 Bluetooth mouse, and Asus I2C interface trackpad

Comment
Add comment · Show 3
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 tonytopper · Aug 29, 2018 at 06:12 PM 0
Share

Having a similar problem. Code is inside Update() functions I presume?

avatar image JVene tonytopper · Aug 29, 2018 at 09:21 PM 0
Share

Well......the original question was posted Februrary 2017. No answers or other comments until today, about 1.5 years later. I'd suggest you start a new question on this if you like.

avatar image ericchen1248 tonytopper · Aug 30, 2018 at 02:03 AM 0
Share

I don't recall it happening again in my subsequent projects, so that was either a project bug, or bug in the unity version. Does it occur in a new project? Are you recent unity versions? If so, you'd be better off starting a new question like the guy above said.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by RX187 · Aug 31, 2018 at 12:43 AM

@ericchen1248 , @tonytopper

 public float minSize, maxSize;
 public float zoomSensitivity;
     
 public void CamZoom()
     {
         float fov = Camera.main.orthographicSize;
     
         fov -= Input.GetAxis("Mouse ScrollWheel") * zoomSensitivity;
         fov = Mathf.Clamp(fov, minSize, maxSize);
         Camera.main.orthographicSize = fov;
     }

 
 
 

Comment
Add comment · Show 2 · 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 RX187 · Aug 31, 2018 at 12:43 AM 0
Share

And also add CamZoom() in Update;

avatar image ericchen1248 · Aug 31, 2018 at 02:03 AM 0
Share

That doesn't help that situation before. The problem was that Input.GetAxis("$$anonymous$$ouse ScrollWheel") would only return a non-zero value when clicked in on the scroll wheel.

It was either some other settings with Input, or a Unity Project/Version bug.

avatar image
0

Answer by robwillson · Apr 02, 2019 at 01:44 AM

I had this issue, and for me the culprit was something I'd put in to cut down on individual checks for various keyboard inputs: if(!Input.anyKey) return;.


anyKey is a bool which returns "is any key or mouse button currently held down". This includes all keyboard and mouse buttons, but (with my mouse at least) does not include scrolling the mouse wheel. Pressing in the mouse wheel does count as a button press, so bypasses the anyKey check, as described by the OP.


If this anyKey thing is your issue then the solutions are simple...


Solution 1 - Place your code for mouse scrollwheel above the anyKey check:

 private void Update () {
     // Code to process your scrollwheel input here
     if (!Input.anyKey) {
         // No keyboard or mouse buttons are currently being pressed, skip further checks
         return;
     }
     // Code to process mouse/keyboard input here
 }


Solution 2 - Add an extra check specifically for the scroll wheel with mouseScrollDelta

 private void Update () {
     if (!Input.anyKey && Input.mouseScrollDelta == Vector2.zero) {
         // No keyboard or mouse buttons are currently being pressed, skip further checks
         return;
     }
     // Code to process mouse/keyboard/scrollwheel input here
 }
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

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

8 People are following this question.

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

Related Questions

ScrollWheel Input not detected in script 2 Answers

Returning mouse scroll as a keycode 1 Answer

Unity 5 tree creator not working correctly. 0 Answers

ServerReturnToLobby() not workiing 0 Answers

Strange animation glitch-mangled character 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