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 );
Unity中的Time和Time.timeScale对协程的yield的影响
最新推荐文章于 2023-05-17 17:45:18 发布