docs.unity.cn
    Show / Hide Table of Contents

    Method clamp

    clamp(Int32, Int32, Int32)

    Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are int values.

    Declaration
    public static int clamp(int valueToClamp, int lowerBound, int upperBound)
    Parameters
    Type Name Description
    Int32 valueToClamp

    Input value to be clamped.

    Int32 lowerBound

    Lower bound of the interval.

    Int32 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    Int32

    The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(int2, int2, int2)

    Returns the result of a componentwise clamping of the int2 x into the interval [a, b], where a and b are int2 vectors.

    Declaration
    public static int2 clamp(int2 valueToClamp, int2 lowerBound, int2 upperBound)
    Parameters
    Type Name Description
    int2 valueToClamp

    Input value to be clamped.

    int2 lowerBound

    Lower bound of the interval.

    int2 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    int2

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(int3, int3, int3)

    Returns the result of a componentwise clamping of the int3 x into the interval [a, b], where x, a and b are int3 vectors.

    Declaration
    public static int3 clamp(int3 valueToClamp, int3 lowerBound, int3 upperBound)
    Parameters
    Type Name Description
    int3 valueToClamp

    Input value to be clamped.

    int3 lowerBound

    Lower bound of the interval.

    int3 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    int3

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(int4, int4, int4)

    Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are int4 vectors.

    Declaration
    public static int4 clamp(int4 valueToClamp, int4 lowerBound, int4 upperBound)
    Parameters
    Type Name Description
    int4 valueToClamp

    Input value to be clamped.

    int4 lowerBound

    Lower bound of the interval.

    int4 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    int4

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(UInt32, UInt32, UInt32)

    Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are uint values.

    Declaration
    public static uint clamp(uint valueToClamp, uint lowerBound, uint upperBound)
    Parameters
    Type Name Description
    UInt32 valueToClamp

    Input value to be clamped.

    UInt32 lowerBound

    Lower bound of the interval.

    UInt32 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    UInt32

    The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(uint2, uint2, uint2)

    Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are uint2 vectors.

    Declaration
    public static uint2 clamp(uint2 valueToClamp, uint2 lowerBound, uint2 upperBound)
    Parameters
    Type Name Description
    uint2 valueToClamp

    Input value to be clamped.

    uint2 lowerBound

    Lower bound of the interval.

    uint2 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    uint2

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(uint3, uint3, uint3)

    Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are uint3 vectors.

    Declaration
    public static uint3 clamp(uint3 valueToClamp, uint3 lowerBound, uint3 upperBound)
    Parameters
    Type Name Description
    uint3 valueToClamp

    Input value to be clamped.

    uint3 lowerBound

    Lower bound of the interval.

    uint3 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    uint3

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(uint4, uint4, uint4)

    Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are uint4 vectors.

    Declaration
    public static uint4 clamp(uint4 valueToClamp, uint4 lowerBound, uint4 upperBound)
    Parameters
    Type Name Description
    uint4 valueToClamp

    Input value to be clamped.

    uint4 lowerBound

    Lower bound of the interval.

    uint4 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    uint4

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(Int64, Int64, Int64)

    Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are long values.

    Declaration
    public static long clamp(long valueToClamp, long lowerBound, long upperBound)
    Parameters
    Type Name Description
    Int64 valueToClamp

    Input value to be clamped.

    Int64 lowerBound

    Lower bound of the interval.

    Int64 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    Int64

    The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(UInt64, UInt64, UInt64)

    Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are ulong values.

    Declaration
    public static ulong clamp(ulong valueToClamp, ulong lowerBound, ulong upperBound)
    Parameters
    Type Name Description
    UInt64 valueToClamp

    Input value to be clamped.

    UInt64 lowerBound

    Lower bound of the interval.

    UInt64 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    UInt64

    The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(Single, Single, Single)

    Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are float values.

    Declaration
    public static float clamp(float valueToClamp, float lowerBound, float upperBound)
    Parameters
    Type Name Description
    Single valueToClamp

    Input value to be clamped.

    Single lowerBound

    Lower bound of the interval.

    Single upperBound

    Upper bound of the interval.

    Returns
    Type Description
    Single

    The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(float2, float2, float2)

    Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are float2 vectors.

    Declaration
    public static float2 clamp(float2 valueToClamp, float2 lowerBound, float2 upperBound)
    Parameters
    Type Name Description
    float2 valueToClamp

    Input value to be clamped.

    float2 lowerBound

    Lower bound of the interval.

    float2 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    float2

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(float3, float3, float3)

    Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are float3 vectors.

    Declaration
    public static float3 clamp(float3 valueToClamp, float3 lowerBound, float3 upperBound)
    Parameters
    Type Name Description
    float3 valueToClamp

    Input value to be clamped.

    float3 lowerBound

    Lower bound of the interval.

    float3 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    float3

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(float4, float4, float4)

    Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are float4 vectors.

    Declaration
    public static float4 clamp(float4 valueToClamp, float4 lowerBound, float4 upperBound)
    Parameters
    Type Name Description
    float4 valueToClamp

    Input value to be clamped.

    float4 lowerBound

    Lower bound of the interval.

    float4 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    float4

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(Double, Double, Double)

    Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are double values.

    Declaration
    public static double clamp(double valueToClamp, double lowerBound, double upperBound)
    Parameters
    Type Name Description
    Double valueToClamp

    Input value to be clamped.

    Double lowerBound

    Lower bound of the interval.

    Double upperBound

    Upper bound of the interval.

    Returns
    Type Description
    Double

    The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(double2, double2, double2)

    Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are double2 vectors.

    Declaration
    public static double2 clamp(double2 valueToClamp, double2 lowerBound, double2 upperBound)
    Parameters
    Type Name Description
    double2 valueToClamp

    Input value to be clamped.

    double2 lowerBound

    Lower bound of the interval.

    double2 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    double2

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(double3, double3, double3)

    Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are double3 vectors.

    Declaration
    public static double3 clamp(double3 valueToClamp, double3 lowerBound, double3 upperBound)
    Parameters
    Type Name Description
    double3 valueToClamp

    Input value to be clamped.

    double3 lowerBound

    Lower bound of the interval.

    double3 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    double3

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    clamp(double4, double4, double4)

    Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are double4 vectors.

    Declaration
    public static double4 clamp(double4 valueToClamp, double4 lowerBound, double4 upperBound)
    Parameters
    Type Name Description
    double4 valueToClamp

    Input value to be clamped.

    double4 lowerBound

    Lower bound of the interval.

    double4 upperBound

    Upper bound of the interval.

    Returns
    Type Description
    double4

    The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].

    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