Unityコルーチン
Unityのコルチーンのやつを動かしてみた
http://www.wisdomsoft.jp/656.html
using UnityEngine; using System.Collections; public class TownMenu : MonoBehaviour { void Start () { IEnumerator temp = Coroutine (); StartCoroutine(Coroutine()); temp.MoveNext(); //One temp.MoveNext(); //Two temp.MoveNext(); //Three StartCoroutine(RotateObject()); } IEnumerator Coroutine() { Debug.Log("One"); yield return null; Debug.Log("Two"); yield return null; Debug.Log("Three"); yield return null; } IEnumerator RotateObject() { var startTime = Time.time; Debug.Log("Begin Coroutine"); while (Time.time - startTime < 5) { transform.Rotate(0, 100*Time.deltaTime ,0); yield return null; } Debug.Log("End Coroutine"); } void Update () { } }
このコードをCubeに貼っつけるとぐるぐる回ります
StartCoroutineは自動でUpdateのたびに呼び出してみてくれるみたい
Time.deltaTimeがないと、RotateObjectの呼び出し頻度がばらつくので
回転速度が安定しないようです