【m】修改dispose方法

This commit is contained in:
2025-07-31 17:36:17 +08:00
parent 6fe53f102f
commit 72895a3b4d
3 changed files with 28 additions and 15 deletions

View File

@@ -9,7 +9,7 @@ namespace Stary.Evo
/// 架构 /// 架构
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public abstract class Architecture<T> : IArchitecture where T : Architecture<T>, new() public abstract class Architecture<T> : IDisposable, IArchitecture where T : Architecture<T>, new()
{ {
/// <summary> /// <summary>
/// 是否已经初始化完成 /// 是否已经初始化完成
@@ -91,7 +91,7 @@ namespace Stary.Evo
} }
// // 提供一个释放模块的 API // // 提供一个释放模块的 API
public void Dispose() public void OnDispose()
{ {
for (int i = 0; i < mArchitecture.mSystems.Count; i++) for (int i = 0; i < mArchitecture.mSystems.Count; i++)
{ {
@@ -102,8 +102,9 @@ namespace Stary.Evo
{ {
mArchitecture.mDatas[i].Dispose(); mArchitecture.mDatas[i].Dispose();
} }
_mEnumEventSystem.Dispose(); _mEnumEventSystem.Dispose();
_mEnumEventSystem=null; _mEnumEventSystem = null;
mArchitecture = null; mArchitecture = null;
} }
@@ -336,46 +337,53 @@ namespace Stary.Evo
/// </summary> /// </summary>
/// <param name="onEvent"></param> /// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent>(TEvent key, Action onEvent)where TEvent : IConvertible public void UnRegisterEvent<TEvent>(TEvent key, Action onEvent) where TEvent : IConvertible
{ {
_mEnumEventSystem.UnRegister(key,onEvent); _mEnumEventSystem.UnRegister(key, onEvent);
} }
/// <summary> /// <summary>
/// 事件销毁 /// 事件销毁
/// </summary> /// </summary>
/// <param name="onEvent"></param> /// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent, Tvalue1>(TEvent key, Action< Tvalue1> onEvent)where TEvent : IConvertible public void UnRegisterEvent<TEvent, Tvalue1>(TEvent key, Action<Tvalue1> onEvent) where TEvent : IConvertible
{ {
_mEnumEventSystem.UnRegister(key,onEvent); _mEnumEventSystem.UnRegister(key, onEvent);
} }
/// <summary> /// <summary>
/// 事件销毁 /// 事件销毁
/// </summary> /// </summary>
/// <param name="onEvent"></param> /// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent, Tvalue1, Tvalue2>(TEvent key, Action<Tvalue1, Tvalue2> onEvent)where TEvent : IConvertible public void UnRegisterEvent<TEvent, Tvalue1, Tvalue2>(TEvent key, Action<Tvalue1, Tvalue2> onEvent)
where TEvent : IConvertible
{ {
_mEnumEventSystem.UnRegister(key,onEvent); _mEnumEventSystem.UnRegister(key, onEvent);
} }
/// <summary> /// <summary>
/// 事件销毁 /// 事件销毁
/// </summary> /// </summary>
/// <param name="onEvent"></param> /// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent, Tvlue1, Tvlue2, Tvlue3>(TEvent key, Action<Tvlue1, Tvlue2, Tvlue3> onEvent)where TEvent : IConvertible public void UnRegisterEvent<TEvent, Tvlue1, Tvlue2, Tvlue3>(TEvent key, Action<Tvlue1, Tvlue2, Tvlue3> onEvent)
where TEvent : IConvertible
{ {
_mEnumEventSystem.UnRegister(key,onEvent); _mEnumEventSystem.UnRegister(key, onEvent);
} }
/// <summary> /// <summary>
/// 事件销毁 /// 事件销毁
/// </summary> /// </summary>
/// <param name="onEvent"></param> /// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent>(TEvent key, Action<object[]> onEvent)where TEvent : IConvertible public void UnRegisterEvent<TEvent>(TEvent key, Action<object[]> onEvent) where TEvent : IConvertible
{ {
_mEnumEventSystem.UnRegister(key,onEvent); _mEnumEventSystem.UnRegister(key, onEvent);
} }
public TResult SendQuery<TResult>(IQuery<TResult> query) public TResult SendQuery<TResult>(IQuery<TResult> query)
{ {
return DoQuery<TResult>(query); return DoQuery<TResult>(query);
@@ -386,5 +394,10 @@ namespace Stary.Evo
query.SetArchitecture(this); query.SetArchitecture(this);
return query.Do(); return query.Do();
} }
public void Dispose()
{
OnDispose();
}
} }
} }

View File

@@ -170,6 +170,6 @@ namespace Stary.Evo
TResult SendQuery<TResult>(IQuery<TResult> query); TResult SendQuery<TResult>(IQuery<TResult> query);
void Dispose(); void OnDispose();
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "com.staryevo.main", "name": "com.staryevo.main",
"version": "1.3.27", "version": "1.3.28",
"displayName": "00.StaryEvo", "displayName": "00.StaryEvo",
"description": "This is an Framework package(后台服务器版本端口9527)", "description": "This is an Framework package(后台服务器版本端口9527)",
"unity": "2021.3", "unity": "2021.3",