Exemplo n.º 1
0
 public static int Int(int min, int max)
 {
     if (MainThreadTest.OnMainThread())
     {
         return(UnityEngine.Random.Range(min, max));
     }
     else
     {
         return(random.Next(min, max));
     }
 }
Exemplo n.º 2
0
 public static bool Bool()
 {
     if (MainThreadTest.OnMainThread())
     {
         return(UnityEngine.Random.Range(0, 2) == 0);
     }
     else
     {
         return(random.Next(0, 2) == 0);
     }
 }
Exemplo n.º 3
0
 public static float Float(float min, float max)
 {
     if (MainThreadTest.OnMainThread())
     {
         return(UnityEngine.Random.Range(min, max));
     }
     else
     {
         return((float)((random.NextDouble() * (max - min)) + min));
     }
 }
Exemplo n.º 4
0
    public static T EnumValue <T>() where T : struct, IConvertible
    {
        if (!typeof(T).IsEnum)
        {
            throw new ArgumentException("T must be an enumerated type.");
        }
        var values = Enum.GetValues(typeof(T));

        if (MainThreadTest.OnMainThread())
        {
            return((T)values.GetValue(UnityEngine.Random.Range(0, values.Length)));
        }
        else
        {
            return((T)values.GetValue(random.Next(values.Length)));
        }
    }