docs.unity3d.com
    Show / Hide Table of Contents

    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.

    Inheritance
    Object
    InputProcessor
    InputProcessor<Single>
    NormalizeProcessor
    Inherited Members
    InputProcessor<Single>.ProcessAsObject(Object, InputControl)
    InputProcessor<Single>.Process(Void*, Int32, InputControl)
    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)

    Normalize value with respect to min and max.

    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
    UnityEngine.InputSystem.InputProcessor<System.Single>.Process(System.Single, UnityEngine.InputSystem.InputControl)

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    See Also

    NormalizeVector2Processor
    NormalizeVector3Processor
    In This Article
    • Fields
      • max
      • min
      • zero
    • Methods
      • Normalize(Single, Single, Single, Single)
      • Process(Single, InputControl)
      • ToString()
    • See Also
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023