jeudi 16 janvier 2020

Unity C# How do I make a random number that doesn't repeat?

I am trying to make code that gives me a random variable from a list of strings, but I do not want it to give me a variable I already got.

Here some code for u my dude ↓↓↓

    public Text[] elements;
    public string[] variables;

    void Start()
    {
        for (int i = 0; i < elements.Length; i++)
        {
            elements[i].text = variables[Random.Range(0, variables.Length)];           
        }
    }



Aucun commentaire:

Enregistrer un commentaire