update 主程序逻辑

This commit is contained in:
2024-10-19 16:46:07 +08:00
parent 71484ea988
commit 7badf4a6af
5 changed files with 36 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
using Framework.Utils;
using StateSystem;
using UnityEditor;
using UnityEngine;
namespace System
@@ -24,8 +25,19 @@ namespace System
[UnityEditor.InitializeOnLoadMethod]
static void InitializeOnLoadMethod()
{
UnityEditor.EditorApplication.wantsToQuit -= OnExit;
UnityEditor.EditorApplication.wantsToQuit += OnExit;
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 ()

View File

@@ -47,8 +47,19 @@ namespace StateSystem.State
// return;
//初始化资源管理器并挂载AlwaysRes下的所有资源
AssetManager.Instance.Rouse ();
this._sceneLoader = new SceneLoader (SceneName.InitScene, true);
this._sceneLoader.BeginLoad (null, ManagerInit);
#if UNITY_EDITOR
ManagerInit ();
return;
#endif
if (SceneManager.GetActiveScene ().name != SceneName.InitScene.ToString ())
{
this._sceneLoader = new SceneLoader (SceneName.InitScene, true);
this._sceneLoader.BeginLoad (null, ManagerInit);
}
else
{
ManagerInit ();
}
}
protected override void OnExit ()
@@ -127,7 +138,8 @@ namespace StateSystem.State
{
GameUpdateMgr.Instance.CreateTimer (1f , () =>
{
this.stateMachineRunner.OpenState (GameGlobalState.GameLogin);
BeginStaticPanel.ReleasePanel ();
this.stateMachineRunner.OpenState (GameGlobalState.GameRoom);
});
}
}

View File

@@ -29,8 +29,9 @@ namespace StateSystem.State
Debug.Log ("Asset pre load " + AssetManager.ResRootPath + "AutoSource/");
AssetManager.Instance.LoadAssets<Object>(AssetManager.ResRootPath + "AutoSource/");
PoolObjectPreload ();
GameManager.Instance.StartAutoSave ();
LoadScene ();
// GameManager.Instance.StartAutoSave ();
// LoadScene ();
OnActived ();
}