Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Possible bug with Custom Processor?

Discussion in 'Input System' started by TehNinjor, Nov 17, 2019.

  1. TehNinjor

    TehNinjor

    Joined:
    Jan 18, 2015
    Posts:
    3
    Im using 2019.2.12f1

    Sorry if I'm missing something dumb, I'm new to the Input System and only just getting a grip on it.

    The InputAction is defined within a MonoBehaviour, and binding is set in the inspector. I will see if this happens in an ActionMap asset as well.

    I'm trying to write a simple processor to smoothDamp() a Vector2. I copy-pasta'd Unity's example of a custom processor and put my bit of code in. So it's registering correctly etc (or at least how they say so as of yet).

    My code worked fine (smoothing correctly, although a tad glitchy when the stick centers), and when I removed the processor from the Binding (via the inspector, editing the Mono), it disappeared from the processors list when I went to re-select it.

    I commented out all my code, and simply returned the input value on Process() (in case it was my doing), but it didn't pop back up.

    There are no errors in the console.

    It wasn't untill I restarted my Editor it reappeared.

    I can re-create this pretty successfully; if I remove it from the binding, it disappears. All the Unity ones seem okay.

    Hopefully this formats right, but here's the class. My code is left commented out just to rule it out, it disappearing exactly as you see it now. It is copy+paste of the example aside from my commented out bits.

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3. using UnityEngine.InputSystem;
    4.  
    5. #if UNITY_EDITOR
    6. [InitializeOnLoad]
    7. #endif
    8. public class SmoothVector2 : InputProcessor<Vector2>
    9. {
    10.     //public float smoothCoef = 0.1f;
    11.     //private Vector2 _vector = new Vector2(0, 0), _vectorRef = new Vector2(0, 0);
    12.  
    13. #if UNITY_EDITOR
    14.     static SmoothVector2()
    15.     {
    16.         Initialize();
    17.     }
    18. #endif
    19.  
    20.     [RuntimeInitializeOnLoadMethod]
    21.     static void Initialize()
    22.     {
    23.         InputSystem.RegisterProcessor<SmoothVector2>();
    24.     }
    25.  
    26.     public override Vector2 Process(Vector2 value, InputControl control)
    27.     {
    28.        //_vector = new Vector2(Mathf.SmoothDamp(_vector.x, value.x, ref _vectorRef.x, smoothCoef),
    29.        //     Mathf.SmoothDamp(_vector.y, value.y, ref _vectorRef.y, smoothCoef));
    30.        // return _vector;
    31.  
    32.         return value;
    33.     }
    34.  
    35.     //...
    36. }
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,387
    That indeed sounds like a bug. Not sure why it would disappear. Shouldn't. Could you file a bug with your repro using the Unity bug reporter? Would like to take a closer look.
     
  3. TehNinjor

    TehNinjor

    Joined:
    Jan 18, 2015
    Posts:
    3
    Sent.

    Not sure what files you'd need exactly, so I just let it send my entire project folder, it's not too big or complicated. I've pointed out the relevant file names in my report.

    If needed, I could record a video of me recreating it, but I think my guide should cover it pretty well, presuming it happens for you too.

    Thanks!
     
    Rene-Damm likes this.
  4. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    143
    I think I'm having the same issue. All custom processors, composites, and interactions disappear from their respective menus after entering playmode. Only ways to get them registered again is to restart the editor or force a domain reload.
     
  5. TehNinjor

    TehNinjor

    Joined:
    Jan 18, 2015
    Posts:
    3
    Yeah that sounds about the same actually, just I thought it was when I removed it form the list. Didn't think to try trying to see if it was still there before removing it.

    I really do appreciate the work-load and time this process takes, but wondering if there's any news about this? If you're having any issues re-creating it I'm happy to do that video and/or help out any way I can etc... :)
     
  6. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    62
    Same issue here, the custom processor appears and disappears sporadically... I force domain reload by checking Domain Reload and playing the game in the editor, then stopping. But it doesn't always work either, so I cannot have a perfect issue repro nor workaround. Last time I had to modify a random line of code to trigger recompile, then re-enter Play Mode, but I don't know if it's necessary.
     
unityunity