-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.cs
More file actions
100 lines (79 loc) · 2.34 KB
/
Main.cs
File metadata and controls
100 lines (79 loc) · 2.34 KB
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
using UnityEngine;
public class Main : MonoBehaviour
{
public void Update()
{
TimerManager.Self.OnUpdate(Time.deltaTime);
}
private GameObject _obj;
public long _countDownTimerId = 0;
public long _printTipTimerId = 0;
public void OnGUI()
{
if (GUILayout.Button("等待5秒 打印 Hello"))
{
Timer.Wait(
5,
() => Debug.Log("Hello"));
}
if (GUILayout.Button("5秒倒计时 打印每秒更新"))
{
Timer.CountDown(
5,
() => Debug.Log("倒计时结束"),
second => { Debug.Log(second); });
}
if (GUILayout.Button("测试A 5秒倒计时 开始"))
{
_countDownTimerId = Timer.CountDown(
5,
() => Debug.Log("倒计时结束"),
second => { Debug.Log(second); });
}
if (GUILayout.Button("测试A 5秒倒计时 中途取消"))
{
Timer.Cancel(_countDownTimerId);
}
if (GUILayout.Button("测试A 5秒倒计时 重新开始倒计时"))
{
_countDownTimerId = Timer.CountDown(
5,
() => Debug.Log("倒计时结束"),
second => { Debug.Log(second); });
}
if (GUILayout.Button("测试B Run 开始 创建关注的GameObject"))
{
_countDownTimerId = Timer.RunBySecond(
deltaTime =>{ Debug.Log(deltaTime); },
_obj = new GameObject("_obj"));
}
if (GUILayout.Button("测试B 删除关注的GameObject"))
{
DestroyImmediate(_obj);
}
if (GUILayout.Button("测试C 循环调用"))
{
PrintTip();
}
if (GUILayout.Button("测试C 主动取消 循环调用"))
{
Timer.Cancel(_printTipTimerId);
}
}
public void PrintTip()
{
Timer.Cancel(_printTipTimerId);
Debug.Log("Tip: HI......");
_printTipTimerId = Timer.Wait(3, PrintTip);
}
public void WhenDeInit()
{
Timer.Cancel(_countDownTimerId);
Timer.Cancel(_printTipTimerId);
}
public void WhenReLink()
{
Timer.Cancel(_countDownTimerId);
Timer.Cancel(_printTipTimerId);
}
}