using UnityEngine; using UnityEngine.UI; namespace Model { [ObjectEvent] public class UILoadingComponentEvent : ObjectEvent, IAwake, IStart { public void Awake() { UILoadingComponent self = this.Get(); self.text = self.GetEntity().GameObject.Get("Text").GetComponent(); } public async void Start() { UILoadingComponent self = this.Get(); TimerComponent timerComponent = Game.Scene.GetComponent(); while (true) { await timerComponent.WaitAsync(1000); if (self.Id == 0) { return; } BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.GetComponent(); if (bundleDownloaderComponent == null) { continue; } self.text.text = $"{bundleDownloaderComponent.Progress}%"; } } } public class UILoadingComponent : Component { public Text text; } }