/// <summary>
/// 获取范围内指定个数不重复随机数
/// </summary>
/// <param name="min"></param>
/// <param name="max"></param>
/// <param name="count"></param>
/// <returns></returns>
public static int[] GetRandomNumbersArray(int min, int max, int count)
{
if (count > (max - min + 1) || max < min)
{
return null;
}
int[] result = new int[count];
HashSet<int> set = new HashSet<int>(); //HashSet 不允许重复对象
while (set.Count < count)
{
set.Add(UnityEngine.Random.Range(min, max + 1));
}
set.CopyTo(result);
return result;
}