using UnityEngine; using System; using System.Collections; using System.Collections.Generic; using System.Security.Cryptography; public static class Randomizer { /** * https://stackoverflow.com/questions/273313/randomize-a-listt * If you need a better quality of randomness in your shuffles use the random number generator in System.Security.Cryptography like so: */ public static void Shuffle(this IList list) { RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider(); int n = list.Count; while (n > 1) { byte[] box = new byte[1]; do provider.GetBytes(box); while (!(box[0] < n * (Byte.MaxValue / n))); int k = (box[0] % n); n--; T value = list[k]; list[k] = list[n]; list[n] = value; } } }