using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using MEC; class WaitForSeconds : IEnumerator { float m_Duration; float m_Current; public WaitForSeconds(float second) { m_Duration = second; m_Current = 0; } public object Current { get { return null; } } public bool MoveNext() { m_Current += Time.deltaTime; return m_Current < m_Duration; } public void Reset() { //Debug.Log("Reset"); m_Current = 0; } } public class UI08TestButton : MonoBehaviour { IEnumerator m_Itor; // Use this for initialization void Start () { Consumer(); m_Itor = Speak(); m_Itor.MoveNext(); List a = new List { 1,2,3}; IEnumerator ia = a.GetEnumerator(); Debug.Log("132"); //Timing.RunCoroutine(); //StartCoroutine(Speak2()); } // Update is called once per frame void Update () { IEnumerator wait = m_Itor.Current as IEnumerator; //if (wait != null) //{ // if (!wait.MoveNext()) // { m_Itor.MoveNext(); // } //} } public void Onclickbutton() { Debug.Log("Onclickbutton"); } public IEnumerator Speak() { Debug.Log("Speak 1"); yield return new UnityEngine.WaitForSeconds(3); int a = 10; int b = 30; int c = 40; Debug.Log("Speak 2" + a + b + c); yield return new UnityEngine.WaitForSeconds(3); Debug.Log("Speak 3"); yield return new UnityEngine.WaitForSeconds(3); } public IEnumerator Speak2() { Debug.Log("Speak 1"); yield return new WaitForSeconds(3); Debug.Log("Speak 2"); yield return new WaitForSeconds(3); Debug.Log("Speak 3"); yield return new WaitForSeconds(3); } public void Consumer() { foreach (int i in Integers()) { Debug.Log(i.ToString()); } } public IEnumerable Integers() { yield return 1; yield return 2; yield return 4; yield return 8; yield return 16; yield return 16777216; } }