Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice

New Input System processors not appearing always

Discussion in 'Input System' started by HassanKhallouf, Jun 12, 2020.

  1. HassanKhallouf

    HassanKhallouf

    Joined:
    Mar 5, 2015
    Posts:
    47
    Hello everyone,
    I created a very Input actions in the new input system.
    the movement node is a simple 2D composition with WASD mapping

    I wanted the player to move relative to the orientation of the camera, W will always be the forward of the main camera, so I created a very simple processor for it.

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3. using UnityEngine.InputSystem;
    4.  
    5. #if UNITY_EDITOR
    6. [InitializeOnLoad]
    7. #endif
    8. public class RelativeToCameraProcessor : InputProcessor<Vector2>
    9. {
    10. #if UNITY_EDITOR
    11.     static RelativeToCameraProcessor()
    12.     {
    13.         Initialize();
    14.     }
    15.    
    16.     [RuntimeInitializeOnLoadMethod]
    17.     private static void Initialize()
    18.     {
    19.         InputSystem.RegisterProcessor<RelativeToCameraProcessor>();
    20.     }
    21. #endif
    22.    
    23.     public override Vector2 Process(Vector2 v, InputControl control)
    24.     {
    25.           // Some vector math added here
    26.            return v;
    27.     }
    28. }
    the problem is when I go to the edit of the input mapping, this processor appears sometimes and disappears other times with totally not consistent behavior

    as this image shows, the processor doesn't appear, I restart unity few times and click randomly on stuff and it appears again, few minutes later, it's not there again



    Even on mappings that already has the processor added, it doesn't appear!



    It's driving me nuts, I'm not sure if this is a bug or it's something that I don't understand about the new input system
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Is it disappearing after you're changing scripts and Unity recompiles or going away even without a recompile?

    There is filtering based on value type but in the screenshots you posted, it shouldn't get filtered out. Very much sounds like the editor is losing track of it somehow.
     
  3. HassanKhallouf

    HassanKhallouf

    Joined:
    Mar 5, 2015
    Posts:
    47
    I can't draw a conclusion at all
    most of the times it's after I change some scripts
    but when this happens I restart unity and check if it's there, sometimes it's, sometimes it's not!

    Also even when this is visible, the behavior in the editor is perfect, when I compile it to any platform (Tried windows,mac and webGL) I get errors missing the classes
     
  4. LabOSM

    LabOSM

    Joined:
    Sep 5, 2019
    Posts:
    18
    Same here, when I compile the new scripts the new processor is there. When I press Play in the editor and then press it again to return, it disappears...

    I guess
    [InitializeOnLoad]
    is not running after you exit Play mode
     
  5. cp-

    cp-

    Joined:
    Mar 29, 2018
    Posts:
    54
    @Rene-Damm is there a fix in sight as of yet?
     
  6. MrTimcakes

    MrTimcakes

    Joined:
    Jan 8, 2016
    Posts:
    6
    Still having this issue. Sometimes restarting Unity makes them appear, but it's not ideal.
     
  7. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    151
    The issue extends to other
    InitializeOnLoad/
    RuntimeInitializeOnLoadMethod classes such as custom
    InputBindingComposite. They generally disappear on Play, during Play mode but also after Stop. They then reappear after one script change and recompile.

    Idea for later: try to force register on Play Mode Exit using https://answers.unity.com/questions/447701/event-for-unity-editor-pause-and-playstop-events.html

    Then submit bug report with minimal project with one custom Input Processor and one custom Input Binding Composite script.
     
    Last edited: Mar 13, 2022
  8. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    151
    So I tried

    Code (CSharp):
    1.  
    2.     // in constructor
    3.     EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
    4.  
    5.  
    6.     private static void OnPlayModeStateChanged(PlayModeStateChange playModeStateChange)
    7.     {
    8.         Debug.LogFormat("Play mode change: {0}", playModeStateChange);
    9.  
    10.         if (playModeStateChange == PlayModeStateChange.EnteredEditMode)
    11.         {
    12.             Debug.Log("Initialize due to Entered Edit Mode");
    13.  
    14.             Initialize();
    15.         }
    16.     }
    and Initialize is logged, but it doesn't work (custom input binding composite appeared after Exit Play Mode only once out of 4 attempts)

    I'll write a bug report if I have time, otherwise if any of you do it first just notify us.

    UPDATE: sent bug report
     
    Last edited: Mar 13, 2022
  9. cp-

    cp-

    Joined:
    Mar 29, 2018
    Posts:
    54
    @huulong can you drop the issue id here? Or even better, post the link :)
     
  10. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    151
  11. HassanKhallouf

    HassanKhallouf

    Joined:
    Mar 5, 2015
    Posts:
    47
unityunity