mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-24 00:58:59 -05:00
17 lines
353 B
C#
17 lines
353 B
C#
|
using UnityEngine;
|
||
|
|
||
|
namespace UnityAtoms.Extensions
|
||
|
{
|
||
|
public static class ArrayExtensions
|
||
|
{
|
||
|
public static T GetRandom<T>(this T[] array)
|
||
|
{
|
||
|
if (array == null || array.Length <= 0)
|
||
|
{
|
||
|
return default(T);
|
||
|
}
|
||
|
|
||
|
return array[Random.Range(0, array.Length)];
|
||
|
}
|
||
|
}
|
||
|
}
|