manoel56
5/12/2020 - 2:52 PM

List Shuffle

public static void Shuffle<T>(this IList<T> list) {
  var count = list.Count;
  var lastElement = count - 1;
  for (var i = 0; i < lastElement; ++i) {
    var r = UnityEngine.Random.Range(i, count);
    var tmp = list[i];
    list[i] = list[r];
    list[r] = tmp;
  }
}