Search Unity

Coroutines ,yield and C#

Discussion in 'Scripting' started by AlbertoT, Apr 5, 2010.

  1. AlbertoT

    AlbertoT

    Joined:
    Mar 27, 2009
    Posts:
    159
    Hello

    I am trying to switch from JavaScript to C#
    No problem with JavaScript but it seem that the only instruction is :

    // C# coroutine
    IEnumerator SomeCoroutine () {
    // Wait for one frame
    yield return 0;

    // Wait for two seconds
    yield return new WaitForSeconds (2);
    }
    }

    That's it, that's all
    A little bit sintetic , I would say

    What is IEnumerator ?
    How should I use it ?

    Can you point me at some tutorial / examples ?

    Thanks in advance
     
  2. Lokken

    Lokken

    Joined:
    Apr 23, 2009
    Posts:
    436
  3. Cyclops

    Cyclops

    Joined:
    Jan 31, 2010
    Posts:
    111
    Here's a more Unity-oriented tutorial, by another forum poster: Tutorial Coroutines Part 1.

    John C>
    "For all your days, prepare, and meet them ever alike;
    When you are the anvil, bear - when the hammer, strike."
     
  4. Mani

    Mani

    Joined:
    Jan 12, 2009
    Posts:
    117
    Thanks for the linkback Cyclops