docs.unity.cn
    Show / Hide Table of Contents

    Method CreateFromIndex

    CreateFromIndex(UInt32)

    Constructs a Random instance with an index that gets hashed. The index must not be uint.MaxValue.

    Declaration
    public static Random CreateFromIndex(uint index)
    Parameters
    Type Name Description
    UInt32 index

    An index that will be hashed for Random creation. Must not be uint.MaxValue.

    Returns
    Type Description
    Random

    Random created from an index.

    Remarks

    Use this function when you expect to create several Random instances in a loop.

    Examples
    for (uint i = 0; i < 4096; ++i)
    {
        Random rand = Random.CreateFromIndex(i);
    
        // Random numbers drawn from loop iteration j will be very different
        // from every other loop iteration k.
        rand.NextUInt();
    }
    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