using UnityEngine;
using System.Collections;
public class TestTimeScale : MonoBehaviour {
// Use this for initialization
void Start () {
StartCoroutine( xx() );
}
// Update is called once per frame
void Update() {
if( Input.GetKeyDown( KeyCode.Q ) ) {
Time.timeScale = 0;
}
if( Input.GetKeyDown( KeyCode.Z ) ) {
Time.timeScale = 1;
}
}
private IEnumerator xx() {
//Debug.Log( "begin ----" );
//while( true ) {
//说明:yes:有影响。no:无影响。且将Time.timeScale恢复后会继续执行(而不是网上某些说的不会恢复执行
//yield return null;//no
//yield return new WaitForSeconds( 5.0f );//yes
//yield return new WaitForFixedUpdate();//yes
//yield return new WaitForEndOfFrame();//no
//yield return 2;//no
//Debug.Log( "---------" + Time.timeScale );
//no
//WWW www = new WWW( "www.baidu.com" );
//yield return www;
//Debug.Log( www.bytes.Length +"-----"+Time.timeScale);
// }
}
}
几种time(unity圣典截图):