Skip to content

CoroutineManager.StartCoroutine

BelicusBr edited this page Sep 7, 2024 · 5 revisions

CoroutineManager.StartCoroutine(IEnumerator) Method

Definition

Namespace: Cobilas.GodotEngine.Utility

Starts a collating process from an IEnumerator.

    public static Coroutine StartCoroutine(System.Collections.IEnumerator enumerator)

Parameters

enumerator IEnumerator
This is where the coroutine will be assigned to be initialized.

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());
       }

       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