-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy path008_await.cs
36 lines (35 loc) · 1.33 KB
/
008_await.cs
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
using System.Collections;
[export]
class TestAwait
{
Transform transform;
Text m_text;
Button m_button2;
Button m_button3;
int m_nClickCount = 0;
public void Start()
{
m_text = transform.Find("Text").GetComponent<Text>();
m_button2 = transform.Find("Button").GetComponent<Button>();
m_button2.onClick.AddListener(OnClieckButton);
m_text.text = "脚本界面初化完成";
m_button3 = transform.Find("Button3").GetComponent<Button>();
m_button3.onClick.AddListener(OnClieckButton3);
}
async void OnClieckButton()
{
int nObjectIndex = ++m_nClickCount;
m_text.text = "button is clicked." + nObjectIndex + ",Time:" + os.time_desc();
int nRes = await TestD.LoadPrefab("abc.txt");
m_text.text = "返回值是:" + nRes + ",Time:" + os.time_desc();
GameObject obj = await TestD.LoadPrefabObj("test_await" + nObjectIndex);
UnityObject o = (UnityObject)obj;
m_text.text = "返回 Name:" + obj.name + ", Time:" + os.time_desc();
}
async void OnClieckButton3()
{
m_text.text = "你点我了,请等3秒,Time:" + os.time_desc();
GameObject obj = await TestD.WaitLoadPrefab("Asset/test.prefab", 3.0f);
m_text.text = "3秒到了, Name:" + obj.name + ", Time:" + os.time_desc();
}
};