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. Dismiss Notice

Question Using the Input System in the Editor

Discussion in 'Input System' started by IndieForger, Dec 7, 2022.

  1. IndieForger

    IndieForger

    Joined:
    Dec 31, 2012
    Posts:
    92
    I am looking at Using the Input System in the Editor docs which provide an example of reading pen pressure.

    Is there a way to actually subscribe to actions defined in action maps to make them trigger while in edit mode?

    Assuming we have something like below
    Code (CSharp):
    1. InputAction myAction = inputMap.FindAction("MyMap", throwIfNotFound: true);
    2. myAction.started += (e) => Debug.Log("started");
    3. myAction.started += (e) => Debug.Log("stopped");
    Behaviour is has
    [ExecuteInEditMode]
    attribute but this doesn't seem to have any effect at all.
    Logging
    myAction
    spits it into the console as expected.

    Is there a method or a flag I have to activate to trigger "in-editor" inputs?
     
  2. IndieForger

    IndieForger

    Joined:
    Dec 31, 2012
    Posts:
    92
    From the Editor I tried
    Code (CSharp):
    1. Debug.Log(myAction.ReadValueAsObject());            // returns null
    2. Debug.Log(myAction.ReadValue<Vector2>());        // returns (0,0)
    Clearly not the way...