docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method NextFloat2

    | Improve this Doc View Source

    NextFloat2()

    Returns a uniformly random float2 value with all components in the interval [0, 1).

    Declaration
    public float2 NextFloat2()
    Returns
    Type Description
    float2

    A uniformly random float2 value in the range [0, 1).

    | Improve this Doc View Source

    NextFloat2(float2)

    Returns a uniformly random float2 value with all components in the interval [0, max).

    Declaration
    public float2 NextFloat2(float2 max)
    Parameters
    Type Name Description
    float2 max

    The componentwise maximum value to generate, exclusive.

    Returns
    Type Description
    float2

    A uniformly random float2 value in the range [0, max).

    | Improve this Doc View Source

    NextFloat2(float2, float2)

    Returns a uniformly random float2 value with all components in the interval [min, max).

    Declaration
    public float2 NextFloat2(float2 min, float2 max)
    Parameters
    Type Name Description
    float2 min

    The componentwise minimum value to generate, inclusive.

    float2 max

    The componentwise maximum value to generate, exclusive.

    Returns
    Type Description
    float2

    A uniformly random float2 value in the range [min, max).

    Remarks

    Each component is computed as NextFloat() * (max - min) + min, so floating-point rounding can in rare cases return a component equal to the corresponding component of max rather than strictly less than it. Clamp the result if you require components strictly less than max.

    • Improve this Doc
    • View Source
    In This Article
    Back to top
    Copyright © 2026 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)