2025-09-17 18:56:28 +08:00
|
|
|
using System.Collections;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
using YooAsset;
|
|
|
|
|
|
|
|
|
|
public class GameStart : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
SceneHandle sceneHandle;
|
2025-09-29 11:03:26 +08:00
|
|
|
|
2025-09-17 18:56:28 +08:00
|
|
|
void Start()
|
|
|
|
|
{
|
2025-09-18 10:15:40 +08:00
|
|
|
DontDestroyOnLoad(gameObject);
|
2025-09-29 11:03:26 +08:00
|
|
|
StartCoroutine(StartupSequence());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator StartupSequence()
|
|
|
|
|
{
|
2025-10-09 07:51:05 +08:00
|
|
|
Debug.Log("开始游戏启动流程...");
|
2025-09-29 11:03:26 +08:00
|
|
|
|
|
|
|
|
yield return StartCoroutine(InitializeGameSystems());
|
|
|
|
|
|
|
|
|
|
yield return StartCoroutine(LoadMainScene());
|
|
|
|
|
|
2025-10-09 07:51:05 +08:00
|
|
|
Debug.Log("游戏启动流程完成");
|
2025-09-29 11:03:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator InitializeGameSystems()
|
|
|
|
|
{
|
2025-10-09 07:51:05 +08:00
|
|
|
Debug.Log("初始化游戏系统...");
|
2025-09-29 11:03:26 +08:00
|
|
|
GameSystem.Inst.Init();
|
2025-10-09 07:51:05 +08:00
|
|
|
Debug.Log("游戏系统初始化完成");
|
2025-09-29 11:03:26 +08:00
|
|
|
yield return null;
|
2025-09-17 18:56:28 +08:00
|
|
|
}
|
2025-09-29 11:03:26 +08:00
|
|
|
IEnumerator LoadMainScene()
|
2025-09-17 18:56:28 +08:00
|
|
|
{
|
|
|
|
|
sceneHandle = YooAssets.LoadSceneAsync("MirrorRoomOffline");
|
|
|
|
|
//sceneHandle = YooAssets.LoadSceneAsync("Game");
|
|
|
|
|
sceneHandle.Completed += (handle) =>
|
|
|
|
|
{
|
|
|
|
|
handle.ActivateScene();
|
2025-09-18 10:15:40 +08:00
|
|
|
StartCoroutine(LoadNetWorkHUD());
|
2025-09-17 18:56:28 +08:00
|
|
|
};
|
|
|
|
|
yield return sceneHandle;
|
|
|
|
|
}
|
2025-09-18 10:15:40 +08:00
|
|
|
IEnumerator LoadNetWorkHUD()
|
2025-09-17 18:56:28 +08:00
|
|
|
{
|
2025-09-18 10:15:40 +08:00
|
|
|
AssetHandle _handle = YooAssets.LoadAssetAsync<GameObject>("MyNetWorkHUD");
|
2025-09-17 18:56:28 +08:00
|
|
|
_handle.Completed += (handle) =>
|
|
|
|
|
{
|
2025-09-18 10:15:40 +08:00
|
|
|
GameObject go = Instantiate((GameObject)_handle.AssetObject,GameManager.Inst.MainUICanvas.transform);
|
2025-09-17 18:56:28 +08:00
|
|
|
Debug.Log(_handle.AssetObject);
|
|
|
|
|
};
|
|
|
|
|
yield return _handle;
|
|
|
|
|
}
|
|
|
|
|
}
|