/// <summary> ///生成不重复的随机数 /// </summary> /// <param name="Number">随机数的个数</param> /// <param name="minNum">随机数的下限</param> /// <param name="maxNum">随机数的上限</param> /// <returns></returns> public int[] GetRandomArray(int Number, int minNum, int maxNum) { int j; int[] b = new int[Number]; for (j = 0; j < Number; j++) { int i = Random.Range(minNum, maxNum + 1); int num = 0; for (int k = 0; k < j; k++) { if (b[k] == i) { num = num + 1; } } if (num == 0) { b[j] = i; ///判断不相同才赋值 } else { j = j - 1; } } return b; }