void OnGUI()
{
//当前时间
GUILayout.Label("Current:"+ Time.time);
//上一帧消耗时间
GUILayout.Label("BeforeTime:"+ Time.deltaTime);
//固定增量时间
GUILayout.Label("FixedTime:"+ Time.fixedTime);
//上一帧消耗固定时间
GUILayout.Label("fixeddeltaTime"+Time.fixedDeltaTime);
}
IEnumerator Start ()
{
return Test();
}
IEnumerator Test()
{
Debug.Log("PauseBegin" + Time.time);
yield return new WaitForSeconds(3);
Debug.Log("End" + Time.time);
}
随机数
void Start ()
{
int a = Random.Range(0,100);
float b = Random.Range(0.0f,10.0f);
Debug.Log("int = "+ a);
Debug.Log("float" + b);
}
物体角度旋转的方法
void OnGUI()
{
if(GUILayout.Button("rotation",GUILayout.Height(50)))
{
gameObject.transform.rotation = Quaternion.Euler(0.0f,50.0f,0.0f);
}
if(GUILayout.Button("rotation2333",GUILayout.Height(50)))
{
isRotation = true;
}
}
// Update is called once per frame
void Update ()
{
if(isRotation)
{
gameObject.transform.rotation = Quaternion.Slerp(gameObject.transform.rotation,Quaternion.Euler(0.0f,50.0f,0.0f),Time.time * 0.1f);
}
}
Quaternion.Slerp方法:第一个参数是游戏物体开始的角度,第二个参数是物体结束的角度,第三个参数是完成动作结束的时间。