mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-23 16:48:23 -05:00
19 lines
413 B
C#
19 lines
413 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
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)];
|
||
|
}
|
||
|
}
|
||
|
}
|