diff --git a/Runtime/Extensions/IListExtensions.cs b/Runtime/Extensions/IListExtensions.cs index 238d667..3be8cfc 100644 --- a/Runtime/Extensions/IListExtensions.cs +++ b/Runtime/Extensions/IListExtensions.cs @@ -62,10 +62,13 @@ public static IList Replace(this IList list, T originalValue, T valueTo public static T Random(this IList list) { if (list.Count == 0) return default; + + // Updated based on Robin King's tip about random items https://twitter.com/quoxel/status/1729137730607841755/photo/1 + int seed = (int)DateTime.Now.Ticks; - var r = new System.Random(); + var r = new Random(seed); - var randomIndex = r.Next(list.Count); + var randomIndex = r.Next(0, list.Count); var returnValue = list[randomIndex];