67 lines
1.4 KiB
C#
67 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Cysharp.Threading.Tasks;
|
|
using PhxhSDK.AOT;
|
|
using UnityEngine;
|
|
|
|
namespace PhxhSDK
|
|
{
|
|
public class Main : SingletonMono<Main>
|
|
{
|
|
private static Game _game;
|
|
|
|
private bool _isInited;
|
|
|
|
private void Awake()
|
|
{
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
private void _InitGame()
|
|
{
|
|
SDKManager.GetSingleton().InitEarly();
|
|
_game = new MyGame();
|
|
if (_game == null)
|
|
{
|
|
DebugUtil.LogError("PhxhSDK.Main: no game instance created");
|
|
}
|
|
SDKManager.GetSingleton().Init();
|
|
_game.Init();
|
|
_game.Start();
|
|
}
|
|
|
|
private async void _InitAsync()
|
|
{
|
|
_isInited = false;
|
|
#if USE_YOO
|
|
await YooAssetHelper.Init();
|
|
#endif
|
|
_isInited = true;
|
|
_InitGame();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
_InitAsync();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!_isInited) return;
|
|
_game.Update(Time.deltaTime);
|
|
}
|
|
|
|
private void OnApplicationPause(bool pauseStatus)
|
|
{
|
|
if (!_isInited) return;
|
|
_game.OnApplicationPause(pauseStatus);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
_game.Release();
|
|
SDKManager.Instance.Release();
|
|
}
|
|
}
|
|
}
|