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?