Game.Input.ProhibitionModifierProcessor
Assembly: Assembly-CSharp
Namespace: Game.Input
Type: class
Base: UnityEngine.InputSystem.InputProcessor
Summary:
A simple, stateless input processor for Unity's Input System that transforms a float input value into either float.NaN when the incoming value is non-zero, or 1f when the incoming value is zero. Intended to be used as a modifier on input bindings to "prohibit" or mark inputs when they are active (non-zero). Because it returns NaN for non-zero inputs, downstream logic that consumes the processed value must handle NaN appropriately.
Fields
- This class declares no fields. {{ This processor is stateless and therefore contains no instance fields. }}
Properties
- This class declares no properties. {{ No state or settings are exposed via properties. }}
Constructors
public ProhibitionModifierProcessor()
{{ Uses the compiler-generated default constructor. No initialization is required because the processor is stateless. }}
Methods
public override float Process(float value, InputControl control)
{{ Processes the supplied input value. If value != 0f the method returns float.NaN; otherwise it returns 1f. Typical intent is to mark/flag an input as "prohibited" or "invalid" when it is active. Be careful: returning NaN can propagate through further processing and comparisons — ensure consumers check for float.IsNaN() when appropriate. The control parameter is unused in this implementation but provided by the Input System API for context if needed later. }}
Usage Example
// Register the processor at startup (optional, Input System can also find processors by type inference)
using UnityEngine.InputSystem;
InputSystem.RegisterProcessor<ProhibitionModifierProcessor>();
// Example: attach the processor to an action binding via code
var action = new InputAction("ExampleAction", InputActionType.Value, "<Gamepad>/buttonSouth");
action.AddBinding("<Gamepad>/buttonSouth").WithProcessor<ProhibitionModifierProcessor>();
action.performed += ctx =>
{
float processed = ctx.ReadValue<float>(); // will be 1f when raw == 0, NaN when raw != 0
if (float.IsNaN(processed))
{
// Input is "prohibited" / active — handle accordingly
}
else
{
// processed == 1f — handle the non-active case
}
};
action.Enable();
Notes: - Because this processor returns NaN for non-zero inputs, ensure downstream logic explicitly checks for NaN (float.IsNaN) instead of relying on ordinary equality comparisons. - The processor is safe to use on multiple bindings and is lightweight since it contains no state.