Answers for "how to never have 2 same values from random function in unity"

0

how to never have 2 same values from random function in unity

List<int> usedValues = new List<int>();
 public int UniqueRandomInt(int min, int max)
 {
     int val = Random.Range(min, max);
     while(usedValues.Contains(val))
     {
         val = Random.Range(min, max);
     }
     return val;
 }
Posted by: Guest on July-10-2020

Code answers related to "how to never have 2 same values from random function in unity"

Browse Popular Code Answers by Language