/// <summary> /// Stops the coroutine. /// </summary> /// <param name="callback">Still send a callback if coroutine finished by this.</param> /// <exception cref="ArgumentOutOfRangeException"></exception> private void Stop(bool callback) { switch (Status) { case CoroutineStatus.Running: case CoroutineStatus.Paused: Root.StopCoroutine(coroutine); Status = CoroutineStatus.Finished; if (callback) { OnFinish(); } break; case CoroutineStatus.NotStarted: BulletStormLogger.LogWarning("Coroutine not started."); break; case CoroutineStatus.Finished: BulletStormLogger.Log("Coroutine already finished."); break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Starts or unpause the coroutine. /// </summary> /// <exception cref="ArgumentOutOfRangeException"></exception> public void Start() { switch (Status) { case CoroutineStatus.NotStarted: if (!Application.isPlaying) { BulletStormLogger.LogError("Can't start coroutine in editor."); return; } Status = CoroutineStatus.Running; coroutine = Root.StartCoroutine(Wrapper()); break; case CoroutineStatus.Paused: Status = CoroutineStatus.Running; break; case CoroutineStatus.Running: BulletStormLogger.Log("Coroutine already started."); break; case CoroutineStatus.Finished: BulletStormLogger.LogError("Coroutine is finished. Call 'Restart' if you want to start it again."); break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Pauses the coroutine. /// </summary> /// <exception cref="ArgumentOutOfRangeException"></exception> public void Pause() { switch (Status) { case CoroutineStatus.Running: Status = CoroutineStatus.Paused; break; case CoroutineStatus.NotStarted: BulletStormLogger.LogWarning("Coroutine not started."); break; case CoroutineStatus.Paused: BulletStormLogger.Log("Coroutine already paused."); break; case CoroutineStatus.Finished: BulletStormLogger.LogWarning("Coroutine is finished."); break; default: throw new ArgumentOutOfRangeException(); } }