Skip to content

CoroutineManager.StopAllCoroutines

BelicusBr edited this page Sep 7, 2024 · 3 revisions

CoroutineManager.StopAllCoroutines() Method

Definition

Namespace: Cobilas.GodotEngine.Utility

Ends all open Coroutines.

   public static void StopAllCoroutines()

Examples

using Godot;
using Cobilas.GodotEngine.Utility;

namespace Test {
   public class ClassTest : Node {
       private Coroutine coroutine1;
       private Coroutine coroutine2;
       private Coroutine coroutine3;

       public override void _Ready() {
           coroutine1 = CoroutineManager.StartCoroutine(Coroutine1());
           coroutine2 = CoroutineManager.StartCoroutine(Coroutine2());
           coroutine3 = CoroutineManager.StartCoroutine(Coroutine3());

           //Here all the coroutines that were started will be forcibly terminated.
           CoroutineManager.StopAllCoroutines();
       }

       private IEnumerator Corroutine1() {
           GD.Print("Zé da manga");
           //When the return is null, by default the coroutine is executed as _Process().
           yield return null;
       }

       private IEnumerator Corroutine2() {
           GD.Print("Zé da manga");
           //When the return is RunTimeSecond the coroutine is executed as _Process() with a pre-defined delay.
           yield return new RunTimeSecond(3);
       }

       private IEnumerator Corroutine3() {
           GD.Print("Zé da manga");
           //When the return is RunTimeSecond the coroutine is executed as _PhysicProcess() with a pre-defined delay.
           yield return new FixedRunTimeSecond(3);
       }
   }
}

Applies to

Product Versions
Godot 3.5
.NET Framework 4.7.2 or higher
.NET Standard 2.1 or higher
Package 1.0.0 or higher