参考官方文档:http://docs.unity3d.com/ScriptReference/Random.Range.html
有一点要注意的,
static int Range(int min, int max);
Description
Returns a random integer number between min
[inclusive] and max
[exclusive] (Read Only).
If max
equals min
, min
will be returned. The returned value will never be max
unless min
equals max
.
对于int型随机数,返回的是[min,max)之间的数,不会返回max这个值。
UnityEngine.Random.Range(1,3);只会返回1或者2.