Update
This commit is contained in:
ALEXTANG
2023-07-13 19:40:12 +08:00
parent 79dc302f14
commit 0c51ae7bdd
4 changed files with 8 additions and 8 deletions

View File

@@ -0,0 +1,40 @@
#if TENGINE_UNITY
using TEngine.Core;
using UnityEngine;
namespace TEngine
{
public class GameSystem : MonoBehaviour
{
/// <summary>
/// 初始化框架。
/// </summary>
public static Scene Init()
{
// 初始化框架
GameContext.Init();
new GameObject("[TEngine.Unity]").AddComponent<GameSystem>();
// 框架需要一个Scene来驱动、所以要创建一个Scene、后面所有的框架都会在这个Scene下
// 也就是把这个Scene给卸载掉、框架的东西都会清除掉
return Scene.Create("Unity");
}
public void Awake()
{
DontDestroyOnLoad(gameObject);
}
private void Update()
{
ThreadSynchronizationContext.Main.Update();
SingletonSystem.Update();
}
private void OnApplicationQuit()
{
EventSystem.Instance?.Publish(new OnAppClosed());
GameContext.Close();
}
}
}
#endif