Exemplo n.º 1
0
    void OnGUI()
    {
        GUI.skin = guiSkin;

        //Top coroutine UI buttons code
        //**************************
        // Coroutine that can be reset (and looped): It is an IEnumerable instead of IEnumerator
        //**************************
        if (resettableCoroutine != null)
        {
            if (resettableCoroutine.isRunning())
            {
                if (!resettableCoroutine.isPaused)
                {
                    if (GUI.Button(new Rect(Screen.width / 12, Screen.height / 12, 64, 64), imagePause))
                    {
                        CoroutineManager.PauseCoroutine(resettableCoroutine);
                        //or you could write:
                        //resettableCoroutine.Pause();
                    }
                }
                else
                {
                    if (GUI.Button(new Rect(Screen.width / 12, Screen.height / 12, 64, 64), imagePlay))
                    {
                        CoroutineManager.ResumeCoroutine(resettableCoroutine);
                        //or you could write:
                        //resettableCoroutine.Resume();
                    }
                }
            }
            if (resettableCoroutine.coroutineIEnumerable != null)               //This coroutine is an IEnumerable instead of a IEnumerator: It can be reset
            {
                if (GUI.Button(new Rect(Screen.width / 12, Screen.height * 3 / 12, 64, 64), imageReset))
                {
                    resettableCoroutine.Reset();
                    //or you could write:
                    //CoroutineManager.ResetCoroutine(resettableCoroutine);
                }
            }
        }
        //**************************
        //Normal coroutine (IEnumerator): It cannot be reset or looped by the Coroutine Manager.
        //**************************
        if (normalCoroutine != null)
        {
            if (normalCoroutine.isRunning())
            {
                if (!normalCoroutine.isPaused)
                {
                    if (GUI.Button(new Rect(Screen.width / 12, Screen.height * 8 / 12, 64, 64), imagePause))
                    {
                        CoroutineManager.PauseCoroutine(normalCoroutine);
                        //or you could write:
                        //normalCoroutine.Pause();
                    }
                }
                else
                {
                    if (GUI.Button(new Rect(Screen.width / 12, Screen.height * 8 / 12, 64, 64), imagePlay))
                    {
                        CoroutineManager.ResumeCoroutine(normalCoroutine);
                        //or you could write:
                        //normalCoroutine.Resume();
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
 public void Pause()
 {
     CoroutineManager.PauseCoroutine(this);
 }