UILoadingComponent.cs 1007 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace ETModel
  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. }
  12. }
  13. [ObjectSystem]
  14. public class UiLoadingComponentStartSystem : StartSystem<UILoadingComponent>
  15. {
  16. public override async void Start(UILoadingComponent self)
  17. {
  18. TimerComponent timerComponent = Game.Scene.GetComponent<TimerComponent>();
  19. while (true)
  20. {
  21. await timerComponent.WaitAsync(1000);
  22. if (self.IsDisposed)
  23. {
  24. return;
  25. }
  26. BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.GetComponent<BundleDownloaderComponent>();
  27. if (bundleDownloaderComponent == null)
  28. {
  29. continue;
  30. }
  31. self.text.text = $"{bundleDownloaderComponent.Progress}%";
  32. }
  33. }
  34. }
  35. public class UILoadingComponent : Component
  36. {
  37. public Text text;
  38. }
  39. }