HTML/JavaScript小工具

HTML/JavaScript小工具

2013年12月23日 星期一

yield 2秒後再行動

    1. StartCoroutine(MyMethod());

  1. IEnumerator MyMethod() {
  2. Debug.Log("Before Waiting 2 seconds");
  3. yield return new WaitForSeconds(2);
  4. Debug.Log("After Waiting 2 Seconds")
  5. }
另外還有
WaitForFixedUpdate可以用
using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {
    IEnumerator Example() {
        yield return new WaitForFixedUpdate();
    }
}

沒有留言:

張貼留言