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
Assembly: Unity.InputSystem.dll
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 |
---|---|
float |
Remarks
If the input value goes beyond max, the result is undefined.
See Also
min
Input value (inclusive) that corresponds to 0 or -1 (depending on zero), the lower bound.
Declaration
public float min
Field Value
Type | Description |
---|---|
float |
Remarks
If the input value drops below min, the result is undefined.
See Also
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 |
---|---|
float |
See Also
Methods
Normalize(float, float, float, float)
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 |
---|---|---|
float | value | Input value. |
float | min | Lower bound. See min. |
float | max | Upper bound. See max. |
float | zero | Zero point. See zero. |
Returns
Type | Description |
---|---|
float | Normalized value. |
Remarks
This method performs the same function as Process(float, InputControl).
// Normalize 2 against a [1..5] range. Returns 0.25.
NormalizeProcessor.Normalize(2, 1, 5, 1)
See Also
Process(float, InputControl)
Declaration
public override float Process(float value, InputControl control)
Parameters
Type | Name | Description |
---|---|---|
float | value | Input value. |
InputControl | control | Ignored. |
Returns
Type | Description |
---|---|
float | Normalized value. |
Overrides
See Also
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |