Processor Registration Order

I’m working on a custom control layout and I have a button (trigger) control that is 255 when not pressed and 0 when fully pressed.

I’ve written a custom processor to reverse this so that actions are triggered correctly:

#if UNITY_EDITOR
[InitializeOnLoad]
#endif
[UnityEngine.Scripting.Preserve]
public class ReverseButton : InputProcessor<float>
{
    static ReverseButton()
    {
        InputSystem.RegisterProcessor<ReverseButton>();
    }

    [RuntimeInitializeOnLoadMethod]
    static void Initialize()
    {
    }

    public override float Process(float value, InputControl control)
    {
        return 1.0f - value;
    }
}

Then I assign it to the control as a processor:

[InputControl(layout = "Button", format = "BYTE", processors = "ReverseButton()")]

This works fine in the Input Debugger, but at runtime I get errors that the ReverseButton processor can’t be found and my device cannot be created.

I can register the processor in the static constructor of my layout and that fixes it, but it doesn’t feel right to have to do this in every layout class that might use a custom processor.

Is there any better way for setting the order that things will be registered with the InputSystem?

Where you can, I’d recommend doing all the Register stuff for things you need from a single place in your startup code.

Wondering if that is due to the registration call not happening or simply happening too late. There’s some device re-creation going on after entering play mode (when coming out of the domain reload) and while the code tries to protect against some registrations not yet being available, could be that’s actually ending up raising some error.

Overall, the reliance on explicit registration calls has been a mistake IMO and I hope to get rid of that past 1.0. Relying on registrations happening at the right time has turned out to be brittle. Registrations should really just be auto-discovered and baked into players.