From 2b84911a68251162bc146fe69178017a08682aa2 Mon Sep 17 00:00:00 2001 From: Le Duc Anh Date: Wed, 17 Dec 2025 14:20:23 +0700 Subject: [PATCH] optimize loading --- .../Scripts/SceneLoader/LoadingSceneController.cs | 12 ++++++++++++ Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs | 11 +++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/SceneLoader/LoadingSceneController.cs b/Assets/PerfectWorld/Scripts/SceneLoader/LoadingSceneController.cs index 7c413a6cb0..c8870ab1a7 100644 --- a/Assets/PerfectWorld/Scripts/SceneLoader/LoadingSceneController.cs +++ b/Assets/PerfectWorld/Scripts/SceneLoader/LoadingSceneController.cs @@ -20,6 +20,13 @@ namespace BrewMonster private bool finished; private CancellationTokenSource cts; + private float _progress; + + public void SetProgress(float progress) + { + _progress = progress; + } + public void ShowLoadingScene(bool active) { goContent.SetActive(active); @@ -87,5 +94,10 @@ namespace BrewMonster { loadingText.text = content; } + + void Update() + { + UpdateUI(_progress); + } } } diff --git a/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs b/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs index cbfe003ec0..1219964be3 100644 --- a/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs +++ b/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs @@ -443,11 +443,7 @@ namespace BrewMonster.Scripts.Task string task_data_path = Path.Combine(Application.streamingAssetsPath, "data/tasks.data"); await pTaskMan.LoadTasksFromPack(task_data_path, true, (x) => { - UniTask.Void(async () => - { - await UniTask.SwitchToMainThread(); - LoadingSceneController.Instance.UpdateUI(x); - }); + LoadingSceneController.Instance.SetProgress(x); }, _cts.Token); } #else @@ -458,7 +454,10 @@ namespace BrewMonster.Scripts.Task return false; } string task_data_path = Path.Combine(Application.persistentDataPath, "data/tasks.data"); - await pTaskMan.LoadTasksFromPack(task_data_path, true, (x) => {}, _cts.Token); + await pTaskMan.LoadTasksFromPack(task_data_path, true, (x) => + { + LoadingSceneController.Instance.SetProgress(x); + }, _cts.Token); #endif #if UNITY_ANDROID && !UNITY_EDITOR