UILoadingComponentSystem.cs 836 B

123456789101112131415161718192021222324252627282930313233
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace ET
  4. {
  5. [ObjectSystem]
  6. public class UiLoadingComponentAwakeSystem : AwakeSystem<UILoadingComponent>
  7. {
  8. public override void Awake(UILoadingComponent self)
  9. {
  10. self.text = self.GetParent<UI>().GameObject.Get<GameObject>("Text").GetComponent<Text>();
  11. self.StartAsync().Coroutine();
  12. }
  13. }
  14. public static class UiLoadingComponentSystem
  15. {
  16. public static async ETTask StartAsync(this UILoadingComponent self)
  17. {
  18. long instanceId = self.InstanceId;
  19. while (true)
  20. {
  21. await TimerComponent.Instance.WaitAsync(1000);
  22. if (self.InstanceId != instanceId)
  23. {
  24. return;
  25. }
  26. }
  27. }
  28. }
  29. }