using System; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace AriaPlugin.Runtime.Coroutine { /// /// Corouitneの制御. /// public class Sequencer { #region Const #endregion // Const End. #region Type #endregion // Type End. #region Field private Queue eventList = new Queue(); private bool isWorking = false; #endregion // Field End. #region Property /// /// 実行中かどうか? /// public bool IsWorking { get { return isWorking; } } #endregion // Property End. #region Event #endregion // Event End. #region Method /// /// 実行するCoroutineの登録. /// public void Register(IEnumerator coroutine) { eventList.Enqueue(coroutine); } /// ///   /// public IEnumerator Execute() { isWorking = true; foreach(var sequence in eventList) { yield return sequence; } yield return null; isWorking = false; } #endregion // Method End. } /// /// Sequencerの終了を待つCoroutine. /// public class WaitForSequencer : CustomYieldInstruction { private Sequencer m_sequencer; public WaitForSequencer(GameObject target, Sequencer sequencer) { m_sequencer = sequencer; } public override bool keepWaiting { get { return m_sequencer.IsWorking; } } } }