Range、insideUnitCircle、insideUnitSphere、onUnitSphere、rotation、rotationUniform
| 
					 1 2 3 4 5 6 7  | 
						        Debug.Log("Random.Range:" + Random.Range(1, 3));   //返回 1、2中随机 整数         Debug.Log("Random.Range f:" + Random.Range(1f, 3f));   //返回 1~3中随机 浮点数         Debug.Log("Random.insideUnitCircle:" + Random.insideUnitCircle);    //返回 (-1,-1)~(1,1)中随机 Vector2         Debug.Log("Random.insideUnitSphere:" + Random.insideUnitSphere);    //返回 (-1,-1,-1)~(1,1,1)中随机 Vector3         Debug.Log("Random.onUnitSphere:" + Random.onUnitSphere);    //返回 (-1,-1,-1)~(1,1,1) 球面中随机 Vector3         Debug.Log("Random.rotation:" + Random.rotation);    //返回一个随机旋转角度         Debug.Log("Random.rotationUniform:" + Random.rotationUniform);  //返回一个随机旋转角度(平均分布的)多次的随机数分布会比较均匀  | 
					

Random.InitState
伪随机数。当指定相同随机数种子后,每次运行随机数会与上次运行的相同,常用于多人同步
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14  | 
						    void Start()     {         Random.InitState(1);    //指定随机数种子为1     }     // Update is called once per frame     void Update()     {         if (Input.GetKeyDown(KeyCode.Space))         {             for (int i = 0; i < 2; i++)                 Debug.Log("Random.Range:" + Random.Range(1, 10));         }     }  | 
					

- 本文固定链接: http://www.u3d8.com/?p=2170
 - 转载请注明: 网虫虫 在 u3d8.com 发表过
 
