From d0e1834bd1972b4262d3e9b46ed55698a7f92025 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 30 Apr 2021 22:49:51 +0800 Subject: *misc --- Assets/Test/08_Button/UI08TestButton.cs | 114 ++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Assets/Test/08_Button/UI08TestButton.cs (limited to 'Assets/Test/08_Button/UI08TestButton.cs') diff --git a/Assets/Test/08_Button/UI08TestButton.cs b/Assets/Test/08_Button/UI08TestButton.cs new file mode 100644 index 0000000..9e86710 --- /dev/null +++ b/Assets/Test/08_Button/UI08TestButton.cs @@ -0,0 +1,114 @@ +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; + } + +} -- cgit v1.1-26-g67d0