IndieGame/client/Assets/Ether/Scripts/Common/ActionEvent/ActionEvent.cs

68 lines
1.6 KiB
C#
Raw Normal View History

2024-10-11 10:12:15 +08:00
/********************************************************************
: ActionEvent.cs
:
: 1982614048@qq.com
: 2024/03/29 17:28:19
:
: 2024/04/03 16:06:42
:
*********************************************************************/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace Ether
{
public class ActionEvent : UnityEvent
{
private int count = 0;
public int Count { get => count; }
public object EventData { get; private set; }
public new void AddListener(UnityAction call)
{
base.AddListener(call);
count++;
}
public new void RemoveListener(UnityAction call)
{
base.RemoveListener(call);
count--;
}
public new void RemoveAllListeners()
{
base.RemoveAllListeners();
count = 0;
}
}
public class ActionEvent<T> : UnityEvent<T>
{
private int count = 0;
public int Count { get => count; }
public object EventData { get; private set; }
public new void AddListener(UnityAction<T> call)
{
base.AddListener(call);
count++;
}
public new void RemoveListener(UnityAction<T> call)
{
base.RemoveListener(call);
count--;
}
public new void RemoveAllListeners()
{
base.RemoveAllListeners();
count = 0;
}
}
}