summaryrefslogtreecommitdiff
path: root/Assets/Test/08_Button/UI08TestButton.cs
blob: 9e86710cc71398183f4d0bae27acc33772341e8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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<int> a = new List<int> { 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<int> Integers()
    {
        yield return 1;
        yield return 2;
        yield return 4;
        yield return 8;
        yield return 16;
        yield return 16777216;
    }

}