docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method NextInt

    | Improve this Doc View Source

    NextInt()

    Returns a uniformly random int value in the interval [-2147483647, 2147483647].

    Declaration
    public int NextInt()
    Returns
    Type Description
    int

    A uniformly random integer value.

    | Improve this Doc View Source

    NextInt(int)

    Returns a uniformly random int value in the interval [0, max).

    Declaration
    public int NextInt(int max)
    Parameters
    Type Name Description
    int max

    The maximum value to generate, exclusive.

    Returns
    Type Description
    int

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

    | Improve this Doc View Source

    NextInt(int, int)

    Returns a uniformly random int value in the interval [min, max).

    Declaration
    public int NextInt(int min, int max)
    Parameters
    Type Name Description
    int min

    The minimum value to generate, inclusive.

    int max

    The maximum value to generate, exclusive.

    Returns
    Type Description
    int

    A uniformly random integer between [min, 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)