AlicizaX/Client/Packages/com.alicizax.unity.eventkit/Runtime/Event/EventKit.cs

43 lines
1008 B
C#
Raw Normal View History

2025-01-23 19:06:48 +08:00
using System;
using System.Collections.Generic;
using AlicizaX.Runtime;
namespace AlicizaX.EventKit.Runtime
{
/// <summary>
/// 事件工具类
/// </summary>
public static class EventKit
{
private static EventPublisher _publisher;
public static EventPublisher Publisher => _publisher;
private static List<Action> eventMaps = new List<Action>();
internal static void Init()
{
eventMaps = new List<Action>();
_publisher = new EventPublisher();
}
internal static void Release()
{
_publisher = null;
foreach (var _event in eventMaps)
{
_event();
}
eventMaps.Clear();
}
/// <summary>
/// 外部不允许调用
/// </summary>
/// <param name="action"></param>
public static void AddResetHandler(Action action)
{
eventMaps.Add(action);
}
}
}