diff --git a/GFramework.Core/events/EasyEvents.cs b/GFramework.Core/events/EasyEvents.cs index 6943320..b4d729f 100644 --- a/GFramework.Core/events/EasyEvents.cs +++ b/GFramework.Core/events/EasyEvents.cs @@ -1,4 +1,4 @@ -using GFramework.Core.Abstractions.events; +using GFramework.Core.Abstractions.events; namespace GFramework.Core.events; @@ -37,6 +37,16 @@ public class EasyEvents MGlobalEvents.AddEvent(); } + /// + /// 获取或添加指定类型的全局事件 + /// + /// 事件类型,必须实现IEasyEvent接口且具有无参构造函数 + /// 指定类型的事件实例 + public static T GetOrAdd() where T : IEvent, new() + { + return MGlobalEvents.GetOrAddEvent(); + } + /// /// 添加指定类型的事件到事件字典中 ///