Unity3d 随机数
随机角度
transform.localRotation = Random.rotation;
随机一个List的Item
posList[UnityEngine.Random.Range(0, posList.Count)]
随机数组 ,随机 一个数组 的Item
arry[UnityEngine.Random.Range(0, arry.Length)]
随机枚举
PopEntryType[] randomPopType = (PopEntryType[])Enum.GetValues(typeof(PopEntryType));//把枚举的值保存为一个数组
PopEntryType mvalue = randomPopType[UnityEngine.Random.Range(0, randomPopType.Length)];
随机bool
bool isFacingRight = (UnityEngine.Random.Range(0,2) == 0 ? true : false);
转载请注明原文地址: https://ju.6miu.com/read-1000243.html