- StartCoroutine(MyMethod());
- IEnumerator MyMethod() {
- Debug.Log("Before Waiting 2 seconds");
- yield return new WaitForSeconds(2);
- Debug.Log("After Waiting 2 Seconds")
- }
另外還有
WaitForFixedUpdate可以用
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { IEnumerator Example() { yield return new WaitForFixedUpdate(); } }
沒有留言:
張貼留言