diff --git a/src/CoroutineBase.cs b/src/CoroutineBase.cs index bf88173..107c635 100644 --- a/src/CoroutineBase.cs +++ b/src/CoroutineBase.cs @@ -35,6 +35,8 @@ public class CoroutineBase /// Determines the pause behaviour of this coroutine. /// public CoRunMode RunMode { get; private set; } + + public event Action Stopped; public void StartCoroutine(CoroutineBase coroutine) { @@ -191,6 +193,7 @@ public void Kill() } Parent?.OnChildStopped(this); + Stopped?.Invoke(); } /// diff --git a/src/CoroutineManager.cs b/src/CoroutineManager.cs index 01d91bb..a275d06 100644 --- a/src/CoroutineManager.cs +++ b/src/CoroutineManager.cs @@ -24,6 +24,7 @@ public partial class CoroutineManager : Node public void StartCoroutine(CoroutineBase coroutine) { coroutine.Manager = this; + coroutine.Stopped += () => aliveRootCoroutines.Remove(coroutine); coroutine.Init(); aliveRootCoroutines.Add(coroutine); }