From 4b164542f44debc77868d37bdd02788322ae67ab Mon Sep 17 00:00:00 2001 From: "Nuno \"Omega Leo\" Diogo" Date: Sat, 11 May 2024 11:28:21 +0100 Subject: [PATCH] Updated list extensions --- Runtime/Extensions/IListExtensions.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Runtime/Extensions/IListExtensions.cs b/Runtime/Extensions/IListExtensions.cs index e650bd0..9065502 100644 --- a/Runtime/Extensions/IListExtensions.cs +++ b/Runtime/Extensions/IListExtensions.cs @@ -68,13 +68,11 @@ public static T Random(this IList list) // 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 Random(seed); + var r = UnityEngine.Random.Range(0, list.Count); - var randomIndex = r.Next(0, list.Count); + var returnValue = list[r]; - var returnValue = list[randomIndex]; - - return returnValue ?? list[0]; + return returnValue ?? list.FirstOrDefault(); }