Files
TuanTuan-Engine/Assets/GameFramework/Runtime/Boot.cs

41 lines
1.2 KiB
C#
Raw Normal View History

2025-11-03 17:46:28 +08:00
using Cysharp.Threading.Tasks;
2025-11-03 12:03:21 +08:00
using System.Collections.Generic;
2025-11-03 00:24:36 +08:00
using UnityEngine;
using YooAsset;
2025-11-03 17:46:28 +08:00
using static UnityEngine.Rendering.VirtualTexturing.Debugging;
2025-11-03 00:24:36 +08:00
2025-11-03 17:46:28 +08:00
public class Boot : MonoBehaviour
2025-11-03 00:24:36 +08:00
{
public GameObject MainUICanvas;
public Camera UICamera;
2025-11-03 17:46:28 +08:00
public Camera MainCamera;
2025-11-03 00:24:36 +08:00
public EPlayMode PlayMode = EPlayMode.EditorSimulateMode;
void Awake()
{
#if UNITY_EDITOR
PlayerPrefs.DeleteAll();
#endif
Application.targetFrameRate = 60;
Application.runInBackground = true;
2025-11-03 17:46:28 +08:00
DontDestroyOnLoad(MainUICanvas);
DontDestroyOnLoad(UICamera);
DontDestroyOnLoad(MainCamera);
2025-11-03 00:24:36 +08:00
}
async void Start()
{
GameManager.Inst.UICamera = UICamera;
GameManager.Inst.MainUICanvas = MainUICanvas;
bool updateSuccess = await PatchManager.Inst.StartOperation(PlayMode);
if (updateSuccess)
2025-11-03 17:46:28 +08:00
await EnterGame();
2025-11-03 00:24:36 +08:00
}
2025-11-03 17:46:28 +08:00
private async UniTask EnterGame()
2025-11-03 00:24:36 +08:00
{
Debug.Log("EnterGame");
2025-11-03 17:46:28 +08:00
var assetHandle = YooAssets.TryGetPackage("Main").LoadSceneAsync("Test");
await assetHandle.ToUniTask();
if (assetHandle.Status == EOperationStatus.Succeed)
assetHandle.ActivateScene();
2025-11-03 00:24:36 +08:00
}
}