全修改为unitask

main
刘涛 2024-02-22 13:24:26 +08:00
parent 653ecf2d7b
commit e623c4e19a
2 changed files with 9 additions and 17 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using PhxhSDK.AOT;
using PhxhSDK.AOT.SimpleLoader;
using UnityEngine;
@ -25,8 +26,6 @@ public class GameLauncher : MonoBehaviour
//最大能容忍的下载卡住时长,一旦超过则重新开始下载
// private const float DOWNLOAD_STUCK_TIME_MAX = 10;
private Coroutine _launchCoroutine;
private HybridCLRHelper _hybridCLRHelper;
//version update
@ -48,27 +47,21 @@ public class GameLauncher : MonoBehaviour
private void Start()
{
_launchCoroutine = StartCoroutine(Launch());
Launch();
}
private void OnDestroy()
{
StopCoroutine(_launchCoroutine);
_launchCoroutine = null;
}
private IEnumerator Launch()
private async UniTask Launch()
{
#if UNITY_EDITOR
enableHotUpdate = false;
#endif
#if USE_YOO
yield return YooAssetHelper.Init();
await YooAssetHelper.Init();
#endif
Debug.Log($"Launch Game! enableHotUpdate:{enableHotUpdate}");
yield return VersionCheck();
await VersionCheck();
if (HasContentToDownload)
yield return VersionUpdate();
await VersionUpdate();
if (enableHotUpdate)
{
@ -82,11 +75,11 @@ public class GameLauncher : MonoBehaviour
_hybridCLRHelper.RegistLoader(new SimpleLoader_Addressables());
#endif
yield return _hybridCLRHelper.LoadAssemblies();
await _hybridCLRHelper.LoadAssemblies();
Debug.Log("加载程序集结束!");
}
yield return EnterGame();
await EnterGame();
}
private IEnumerator VersionCheck()
@ -247,7 +240,6 @@ public class GameLauncher : MonoBehaviour
{
Debug.LogError(
$"load scene failed,exception:{op.OperationException.Message} \r\n {op.OperationException.StackTrace}");
yield break;
}
}

@ -1 +1 @@
Subproject commit ec77ab3adb730c08bfc9dc9aa4e661f398108abb
Subproject commit d6a427c9be3372616285a4dda9bb6a900374018d