Beispiel #1
0
        /// <summary>
        /// Runs a coroutine from the given host.
        /// </summary>
        static public CoroutineHandle Run(MonoBehaviour inHost, IEnumerator inRoutine)
        {
            CreateHost();

            CoroutineInstance instance = s_Pool.Pop();
            CoroutineHandle   handle   = instance.Start(s_CurrentIndex, inHost, inRoutine);

            if (s_CurrentIndex == uint.MaxValue)
            {
                s_CurrentIndex = 1;
            }
            else
            {
                ++s_CurrentIndex;
            }
            return(handle);
        }
Beispiel #2
0
 /// <summary>
 /// Starts a smart coroutine.
 /// Smart coroutine simplifies the syntax.
 /// If you yield a number, it will wait that number of seconds to resume.
 /// If you yield an IEnumerator from a coroutine function, it will start that coroutine.
 /// This avoids needing to call StartCoroutine for every subroutine.
 /// <code>yield return StartCoroutine(nameOfMyFunction())</code>
 /// becomes <code>yield return nameOfMyFunction()</code>
 /// </summary>
 static public CoroutineHandle SmartCoroutine(this MonoBehaviour inBehavior, IEnumerator inStart)
 {
     return(CoroutineInstance.Run(inBehavior, inStart));
 }