リスト形式のイベントをwaitとゆう変数がTrueになった際に順番に実行する処理が有るのですが
以下のスクリプトが削除された後再度コルーチンをスタートすると停止してしまいます。
原因が解りません、助けてください。
public List<UnityEvent> events = new List<UnityEvent>(); public bool wait { get;set; } public void Stop() { StopCoroutine(sequenceCoroutine); } public void OnDestroy() { if (sequenceCoroutine != null) StopCoroutine(sequenceCoroutine); sequenceCoroutine = null; } public void BeginSequence(bool _wait) { wait = _wait; sequenceCoroutine = ProcessSequence(); StartCoroutine(sequenceCoroutine); } private IEnumerator ProcessSequence() { foreach (ScriptedSequenceEvent currentEvent in events) { yield return new WaitWhile(() => wait); if (currentEvent.delay > 0f) { yield return new WaitForSeconds(currentEvent.delay); } wait = true; currentEvent.Invoke(); } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。