using System; using System.Collections; using Cysharp.Threading.Tasks; using HK; using Sirenix.OdinInspector; // using UniFramework.Event; using UnityEngine; using UnityEngine.Serialization; using YooAsset; public class Init : MonoBehaviour { /// /// 资源系统运行模式 /// public EPlayMode PlayMode = EPlayMode.EditorSimulateMode; public string packageName = "DefaultPackage"; public string hostServerIP = "http://192.168.1.239:8080/NetworkServer/AssetsFolder/Framework"; public string sceneName = "Assets/Res/Scene/Game.unity"; void Awake() { DontDestroyOnLoad(this.gameObject); #if !UNITY_EDITOR if (PlayMode == EPlayMode.EditorSimulateMode) { PlayMode = EPlayMode.OfflinePlayMode; } #endif } void Start() { AdjustScreenResolution(); InitAsync().Forget(); async UniTask InitAsync() { var initializePackage = new InitializePackage(PlayMode, packageName, hostServerIP,Application.version); await initializePackage.Start(); // 切换到主页面场景 // SceneEventDefine.ChangeToHomeScene.SendEventMessage(); // YooAssets.LoadSceneSync(SceneName); YooAssets.LoadSceneSync(sceneName); } } public void AdjustScreenResolution() { float w = Screen.currentResolution.width; float h = Screen.currentResolution.height; if (w * 16 > h * 9) { Screen.SetResolution((int)(h * (float)((float)9 / 16)), (int)h, true); } else { Screen.SetResolution((int)w, (int)(w * (float)((float)16 / 9)), true); } //#endif } private void Update() { // if (Input.GetKeyDown(KeyCode.A)) // { // } } }