2024-07-04 20:18:43 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using YooAsset;
|
|
|
|
|
|
2024-07-05 13:34:17 +08:00
|
|
|
|
namespace ZGame
|
2024-07-04 20:18:43 +08:00
|
|
|
|
{
|
|
|
|
|
public class Global : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private EPlayMode _loadType = EPlayMode.EditorSimulateMode;
|
2024-07-05 13:34:17 +08:00
|
|
|
|
|
2024-07-04 20:18:43 +08:00
|
|
|
|
[SerializeField] private float time;
|
2024-07-05 13:34:17 +08:00
|
|
|
|
|
|
|
|
|
[SerializeField] private GameInitType _gameInitType = GameInitType.None;
|
2024-07-04 20:18:43 +08:00
|
|
|
|
[SerializeField] private Camera _playerCamera;
|
|
|
|
|
[SerializeField] private Camera _playerUICamera;
|
|
|
|
|
[SerializeField] private AudioListener _eye;
|
|
|
|
|
|
2024-07-05 13:34:17 +08:00
|
|
|
|
[SerializeField] private GameObject uiLoading;
|
|
|
|
|
|
2024-07-04 20:18:43 +08:00
|
|
|
|
private LoadDll loadDll;
|
|
|
|
|
|
2024-07-05 13:34:17 +08:00
|
|
|
|
public EPlayMode playMode => this._loadType;
|
|
|
|
|
|
2024-07-04 20:18:43 +08:00
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
2024-07-05 13:34:17 +08:00
|
|
|
|
Console.Write(String.Empty);
|
2024-07-04 20:18:43 +08:00
|
|
|
|
DontDestroyOnLoad(this.gameObject);
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
// this._loadType = EPlayMode.EditorSimulateMode;
|
|
|
|
|
#elif UNITY_ANDROID|| PLATFORM_ANDROID|| ENABLE_WEBCAM|| UNITY_WEBGL|| UNITY_EDITOR_WIN
|
|
|
|
|
this._loadType = EPlayMode.HostPlayMode;
|
|
|
|
|
#endif
|
|
|
|
|
this.loadDll = new LoadDll();
|
|
|
|
|
this.Initialized().Forget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async UniTask Initialized()
|
|
|
|
|
{
|
|
|
|
|
await ResourceComponent.Instance.InitLoadModeAsync(this._loadType, "DefaultPackage");
|
|
|
|
|
|
|
|
|
|
// loadDll
|
|
|
|
|
await this.loadDll.DownloadAsync();
|
|
|
|
|
|
2024-07-05 13:34:17 +08:00
|
|
|
|
this.loadDll.OnStart(gameObject, playMode, (int)this._gameInitType, Callback);
|
2024-07-04 20:18:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-05 13:34:17 +08:00
|
|
|
|
private void Callback()
|
2024-07-04 20:18:43 +08:00
|
|
|
|
{
|
2024-07-05 13:34:17 +08:00
|
|
|
|
this.uiLoading.SetActive(false);
|
2024-07-04 20:18:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|