Class NormalizeProcessor
Normalizes input values in the range min and max to unsigned normalized form [0..1] if zero is placed at (or below) min or to signed normalized form [-1..1] if zero is placed in-between min and max.
Inherited Members
Namespace: UnityEngine.InputSystem.Processors
Syntax
public class NormalizeProcessor : InputProcessor<float>
Remarks
This processor is registered (see RegisterProcessor<T>(String)) under the name "normalize".
Note that this processor does not clamp the incoming value to min and max. To achieve this, either add a ClampProcessor or use AxisDeadzoneProcessor which combines clamping and normalizing.
// Bind to right trigger on gamepad such that the value values below 0.3 and above 0.7 get normalized
// to values between [0..1].
new InputAction(binding: "<Gamepad>/rightTrigger", processors: "normalize(min=0.3,max=0.7)");
Fields
max
Input value (inclusive) that corresponds to 1, the upper bound.
Declaration
public float max
Field Value
Type | Description |
---|---|
Single |
Remarks
If the input value goes beyond max, the result is undefined.
min
Input value (inclusive) that corresponds to 0 or -1 (depending on zero), the lower bound.
Declaration
public float min
Field Value
Type | Description |
---|---|
Single |
Remarks
If the input value drops below min, the result is undefined.
zero
Input value that corresponds to 0. If this is placed at or below min, the resulting normalization returns a [0..1] value. If this is placed in-between min and max, the resulting normalization returns a [-1..1] value.
Declaration
public float zero
Field Value
Type | Description |
---|---|
Single |
Methods
Normalize(Single, Single, Single, Single)
Normalize value
with respect to min
and max
.
Declaration
public static float Normalize(float value, float min, float max, float zero)
Parameters
Type | Name | Description |
---|---|---|
Single | value | Input value. |
Single | min | Lower bound. See min. |
Single | max | Upper bound. See max. |
Single | zero | Zero point. See zero. |
Returns
Type | Description |
---|---|
Single | Normalized value. |
Remarks
This method performs the same function as Process(Single, InputControl).
// Normalize 2 against a [1..5] range. Returns 0.25.
NormalizeProcessor.Normalize(2, 1, 5, 1)
Process(Single, InputControl)
Declaration
public override float Process(float value, InputControl control)
Parameters
Type | Name | Description |
---|---|---|
Single | value | Input value. |
InputControl | control | Ignored. |
Returns
Type | Description |
---|---|
Single | Normalized value. |
Overrides
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |