Skip to content

Commit

Permalink
Updated list extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
omegaleo committed May 11, 2024
1 parent 01c406f commit 4b16454
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Runtime/Extensions/IListExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@ public static T Random<T>(this IList<T> 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();

}

Expand Down

0 comments on commit 4b16454

Please sign in to comment.