1. using UnityEngine;标签:异步,Log,void,Unity,other,progress,Debug,async,加载 From: https://blog.51cto.com/u_8378185/5990709
2. using System.Collections;
3.
4. public class FightTriggle : MonoBehaviour {
5. private AsyncOperation async;
6. i = 0;
7. void OnTriggerEnter(Collider other)
8. {
9. Debug.Log("打开");
10. other.collider.gameObject.tag == "Player")
11. {
12. //打开副本UI
13. Debug.Log("打开副本");
14. StartCoroutine(GetProgress());
15.
16. }
17.
18. }
19. IEnumerator GetProgress()
20. {
21. async = Application.LoadLevelAsync(0);
22. yield return async;
23. }
24. void Update()
25. {
26. if (async != null)
27. {
28. if (!async.isDone)
29. {
30. progress = async.progress;
31. Debug.Log("加载进度 " + async.progress);
32. i++;
33. Debug.Log("" + i+async.progress);
34. }
35. }
36.
37. }
38. void OnTriggerExit(Collider other)
39. {
40. other.collider.gameObject.tag == "Player")
41. {
42. Debug.Log("关才副本");
43. }
44. }
45. }