Files
taptap2024_GJ_chidouren/Assets/Scripts/System/GameSetup.cs

52 lines
1.4 KiB
C#

using Framework.Utils;
using StateSystem;
using UnityEditor;
using UnityEngine;
namespace System
{
/// <summary>
/// 游戏入口
/// </summary>
public class GameSetup : MonoBehaviour
{
private void Awake()
{
#if DebugLog
DebugLogTrigger.Instance.StartLog();
#endif
#if UNITY_EDITOR
DontDestroyOnLoad (this.gameObject);
return;
#endif
GameStateManager.Instance.Active(StateSystem.GameGlobalState.GameBegin);
}
#if UNITY_EDITOR
[UnityEditor.InitializeOnLoadMethod]
static void InitializeOnLoadMethod()
{
UnityEditor.EditorApplication.playModeStateChanged -= OnPlaying;
UnityEditor.EditorApplication.playModeStateChanged += OnPlaying;
UnityEditor.EditorApplication.wantsToQuit -= OnExit;
UnityEditor.EditorApplication.wantsToQuit += OnExit;
}
//当编辑器运行时
static void OnPlaying (PlayModeStateChange stateChange)
{
if (stateChange == PlayModeStateChange.EnteredPlayMode)
{
GameStateManager.Instance.Active(StateSystem.GameGlobalState.GameBegin);
}
}
static bool OnExit ()
{
CameraEffectUtils.Instance.SetGameCamBlur (0 , 0 , null , BlurEffectType.Blur);
return true;
}
#endif
}
}