mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
支持编辑器下EnterPlayMode Options
This commit is contained in:
@@ -34,6 +34,7 @@ namespace GameLogic
|
||||
|
||||
object obj = Activator.CreateInstance(type, mgr.Dispatcher);
|
||||
|
||||
mgr.Init();
|
||||
mgr.RegWrapInterface(obj.GetType().GetInterfaces()[0]?.FullName, obj);
|
||||
}
|
||||
}
|
||||
|
@@ -62,13 +62,22 @@ namespace TEngine
|
||||
entry.InterfaceWrap = callerWrap;
|
||||
if (typeName != null)
|
||||
{
|
||||
_eventEntryMap.Add(typeName, entry);
|
||||
_eventEntryMap[typeName] = entry;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分发注册器。
|
||||
/// </summary>
|
||||
public EventDispatcher Dispatcher { get; } = new EventDispatcher();
|
||||
public EventDispatcher Dispatcher { get; private set; } = new EventDispatcher();
|
||||
|
||||
/// <summary>
|
||||
/// 清除事件。
|
||||
/// </summary>
|
||||
public void Init()
|
||||
{
|
||||
_eventEntryMap.Clear();
|
||||
Dispatcher = new EventDispatcher();
|
||||
}
|
||||
}
|
||||
}
|
@@ -585,5 +585,13 @@ namespace TEngine
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 清除事件。
|
||||
/// </summary>
|
||||
public static void Shutdown()
|
||||
{
|
||||
_eventMgr.Init();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
@@ -170,5 +173,32 @@ namespace TEngine
|
||||
_timer = null;
|
||||
_resourceExt = null;
|
||||
}
|
||||
|
||||
#region HandlePlayModeStateChanged
|
||||
private void OnEnable()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorApplication.playModeStateChanged += HandlePlayModeStateChanged;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorApplication.playModeStateChanged -= HandlePlayModeStateChanged;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
void HandlePlayModeStateChanged(PlayModeStateChange state)
|
||||
{
|
||||
if (state == PlayModeStateChange.ExitingPlayMode)
|
||||
{
|
||||
ModuleSystem.Shutdown(ShutdownType.Quit);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@@ -87,6 +87,7 @@ namespace TEngine
|
||||
_modules.Clear();
|
||||
|
||||
GameModule.Shutdown(shutdownType);
|
||||
GameEvent.Shutdown();
|
||||
|
||||
if (shutdownType == ShutdownType.None)
|
||||
{
|
||||
|
Reference in New Issue
Block a user