docs.unity.cn

Input System 1.13.1

Search Results for

    Show / Hide Table of Contents

    Class ClampProcessor

    Clamp a floating-point input to between min and max. This is equivalent to Mathf.Clamp(value, min, max).

    Inheritance
    object
    InputProcessor
    InputProcessor<float>
    ClampProcessor
    Inherited Members
    InputProcessor<float>.ProcessAsObject(object, InputControl)
    InputProcessor<float>.Process(void*, int, InputControl)
    InputProcessor.cachingPolicy
    Namespace: UnityEngine.InputSystem.Processors
    Assembly: Unity.InputSystem.dll
    Syntax
    public class ClampProcessor : InputProcessor<float>
    Remarks

    This processor is registered (see RegisterProcessor<T>(string)) under the name "clamp" by default.

    Note that no normalization is performed. If you want to re-normalize the input value after clamping, add a NormalizeProcessor. Alternatively, add a AxisDeadzoneProcessor which both clamps and normalizes.

    // Bind to right trigger on gamepad such that the value never drops below 0.3 and never goes // above 0.7. new InputAction(binding: "<Gamepad>/rightTrigger", processors: "clamp(min=0.3,max=0.7)");

    Fields

    max

    Maximum value (inclusive!) of the accepted value range.

    Declaration
    public float max
    Field Value
    Type Description
    float

    min

    Minimum value (inclusive!) of the accepted value range.

    Declaration
    public float min
    Field Value
    Type Description
    float

    Methods

    Process(float, InputControl)

    Clamp value to the range of min and max.

    Declaration
    public override float Process(float value, InputControl control)
    Parameters
    Type Name Description
    float value

    Input value.

    InputControl control

    Ignored.

    Returns
    Type Description
    float

    Clamped value.

    Overrides
    InputProcessor<float>.Process(float, InputControl)

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()
    In This Article
    • Fields
      • max
      • min
    • Methods
      • Process(float, InputControl)
      • ToString()
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)