docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method NextInt

    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.

    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).

    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).

    In This Article
    Back to top
    Copyright © 2024 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)