optimize loading
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user