Search Unity

[SOLVED] How to get Scroll Wheel Data?

Discussion in 'Input System' started by Patrick_Rainer, Apr 17, 2020.

  1. Patrick_Rainer


    Feb 26, 2018
    Dear All

    How can i correctly get the mouse wheel input?

    In this case the Vector2 is always (0,0).


    Code (CSharp):
    1.         public void OnZoom(InputAction.CallbackContext context)
    2.         {
    3.             Vector2 wheelInput = context.ReadValue<Vector2>();
    5.             if (wheelInput !=
    6.             {
    7.                 Debug.Break();
    8.             }
    10.             //Debug.Log("OnZoom Callback with float: " + wheelDelta.ToString());
    12.             throw new System.NotImplementedException();
    13.         }
  2. Rene-Damm


    Sep 15, 2012
    The "scroll" control is already a Vector2. Remove the Vector2 composite and bind to the scroll control directly.
    Patrick_Rainer likes this.
  3. Patrick_Rainer


    Feb 26, 2018
    Thank you, did work just fine!
  4. Steven_VR


    Jan 11, 2020
    Would be really great if you guys could provide an example how to setup scrolling in the new system. I have to say being a new user trying to understand what is going on through this transition to the new system is extremely painful, confusing, and a massive waste of time.
    Plenty of demos online for the old system which is clearly less robust - but quite frankly WAY more logical for a newb to get into... simply hard code a key and start writing an action..
    Here we are setting up InputActions in a window, creating a C# script, binding it to an object, going to player control options to bind those to areas in our script... then start troubleshooting 3 possible links in the chain...All before we know.... Is my action type right? is my control type right? do I want 1 axis, 2, or 3... if 3 how can I define it (I can't in the tool)....

    I searched the input system docs for scrollwheel... Also searches online (brought me here).

    In the example above - throw us newbs a bone and write a complete answer even though you know the poster is more advanced. It helps us others lurk and learn
    For example a step through...
    For scrolling:
    "Set the action to ___" with the following control types.
    "Add a ___ binding" and set the bindings to scrollwheel x and y"...
    Then you answer "Scroll is already a Vector2 as you can see set above in ___
    etc etc

    If that already exists in a previous post someplace... linking to the previous post in this post also helps until we all understand what this thing is doing and how you expect people to implement standard things like scrollwheels would be a good practice.

    All of this would be wildly helpful until Brackeys, Dapper Dino and the others can hit the various use cases for the new system.

    I do think the new system has massive potential which is why I want to start off by using it... but I also just want to get zoom working so I can create and move on to other things.
    Ditronian, a436t4ataf, bindon and 3 others like this.