Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Error when reading CallbackContext

Discussion in 'Input System' started by quint_unity, Oct 25, 2020.

  1. quint_unity

    quint_unity

    Joined:
    Oct 11, 2020
    Posts:
    13
    I'm receiving an error when utilizing the code below.

    Code (CSharp):
    1.     public void OnMouseScroll(InputAction.CallbackContext context)
    2.     {
    3.         Debug.Log(context.ReadValue<Vector2>());
    4.     }
    5.  
    MissingMember.PNG

    inputsystem.PNG Actions.PNG SendMessage.PNG
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Messages cannot receive InputAction.CallbackContext arguments. Events must be used to receive the full callback context. Messages either need to be without an argument (for buttons) or take an InputValue argument.
     
    solidfrog likes this.
  3. illegallyblonde

    illegallyblonde

    Joined:
    Aug 22, 2015
    Posts:
    6
    Unity should provide a clearer error message for this. I saw quite a few threads asking the same question, and it wastes developer time.
     
  4. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Seconded. Haven't found a single tutorial that explains this aspect properly
     
    Radicals270 and Vaupell like this.