Frame/Assets/Scripts/Game.cs

54 lines
1.4 KiB
C#
Raw Normal View History

2024-04-02 18:17:57 +08:00
using System;
2024-04-03 14:38:44 +08:00
using Cysharp.Threading.Tasks;
2024-04-02 18:17:57 +08:00
using UnityEngine;
namespace Game
{
public class Game : MonoBehaviour
{
private UIManager _uiManager;
private ResourceManager _resourceManager;
[SerializeField] private LoadType _loadType = LoadType.Editor;
[SerializeField] private float time;
private void Awake()
{
DontDestroyOnLoad(this.gameObject);
_uiManager = new UIManager();
_resourceManager = new ResourceManager();
_resourceManager.Init();
_uiManager.Init();
}
private void Start()
{
2024-04-03 14:38:44 +08:00
UniTask.Create(
async () =>
{
await _resourceManager.InitLoadModeAsync(_loadType);
// var loadingGameSceneUI = UIManager.Instance.CreateUI(UIType.LoadingGameSceneUI);
// UIManager.Instance.ShowUI(UIType.LoadingGameSceneUI);
await this._resourceManager.LoadSceneAsync(SceneType.Game.ToString());
return "11";
});
2024-04-02 18:17:57 +08:00
}
private void Update()
{
time += Time.deltaTime;
_resourceManager.Update(time);
_uiManager.Update(time);
}
private void OnDestroy()
{
_resourceManager.Dispose();
_uiManager.Dispose();
}
}
}