Framwork/Assets/Scripts/Base/Init.cs

70 lines
1.7 KiB
C#
Raw Normal View History

2025-06-04 22:49:37 +08:00
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
{
/// <summary>
/// 资源系统运行模式
/// </summary>
public EPlayMode PlayMode = EPlayMode.EditorSimulateMode;
public string packageName = "DefaultPackage";
2025-07-02 10:24:01 +08:00
public string hostServerIP = "http://192.168.1.239:8080/NetworkServer/AssetsFolder/Framework";
2025-06-04 22:49:37 +08:00
public string sceneName = "Assets/Res/Scene/Game.unity";
void Awake()
{
DontDestroyOnLoad(this.gameObject);
}
void Start()
{
2025-06-17 09:31:12 +08:00
AdjustScreenResolution();
2025-06-04 22:49:37 +08:00
InitAsync().Forget();
async UniTask InitAsync()
{
var initializePackage = new InitializePackage(PlayMode, packageName, hostServerIP);
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))
// {
// }
}
}