Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save unitycoder/0a89f366983e457ab125904b301c3f4c to your computer and use it in GitHub Desktop.

Select an option

Save unitycoder/0a89f366983e457ab125904b301c3f4c to your computer and use it in GitHub Desktop.

Revisions

  1. unitycoder revised this gist Dec 11, 2025. No changes.
  2. unitycoder revised this gist Dec 11, 2025. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions callCoRoutineWithoutStartCoroutineFromCoroutine.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    IEnumerator Parent()
    {
    Debug.Log("Parent: before child");

    yield return ChildCoroutine();

    Debug.Log("Parent: after child");
    }

    IEnumerator ChildCoroutine()
    {
    Debug.Log("Child: step 1");
    yield return new WaitForSeconds(1f);
    Debug.Log("Child: step 2");
    }
  3. unitycoder revised this gist Dec 11, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion coroutinecallback.cs
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    });

    int myarg=1;
    StartCoroutine(Tools.ReadLocalImage(myarg, (Bool success) =>
    StartCoroutine(DoSomething(myarg, (Bool success) =>
    {
    if (success)
    {
  4. unitycoder renamed this gist Dec 11, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. unitycoder created this gist Dec 11, 2025.
    31 changes: 31 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    // caller
    StartCoroutine(DoSomething((success) =>
    {

    });

    int myarg=1;
    StartCoroutine(Tools.ReadLocalImage(myarg, (Bool success) =>
    {
    if (success)
    {
    Debug.Log("Success");
    }
    else
    {
    Debug.Log("Failed");
    }
    }
    }));


    // coroutine
    IEnumerator DoSomething(int arg, Action<bool> callback)
    {
    if (arg==0)
    {
    callback(false);
    }

    callback(true);
    }