66 lines
1.6 KiB
C#
66 lines
1.6 KiB
C#
using AibisDream.Kit;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.Framework
|
|
{
|
|
public class EventSystemEx : SingletonBase<EventSystemEx>
|
|
{
|
|
public GameObject pointerOverObj;
|
|
public GameObject draggingObj;
|
|
public GameObject holdingObj;
|
|
|
|
#region 事件触发中转
|
|
|
|
public void OnPointerEnter(IInteraction interaction)
|
|
{
|
|
pointerOverObj = interaction.GetGameObject();
|
|
EnumEventSystem.Global.Send(TriggerEnum.PointerEnter, interaction);
|
|
}
|
|
|
|
public void OnPointerExit(IInteraction interaction)
|
|
{
|
|
if (pointerOverObj == interaction.GetGameObject())
|
|
{
|
|
EnumEventSystem.Global.Send(TriggerEnum.PointerExit, interaction);
|
|
pointerOverObj = null;
|
|
}
|
|
}
|
|
|
|
public void OnPointerDown(IInteraction interaction)
|
|
{
|
|
EnumEventSystem.Global.Send(TriggerEnum.PointerDown, interaction);
|
|
holdingObj = interaction.GetGameObject();
|
|
}
|
|
|
|
public void OnPointerUp(IInteraction interaction)
|
|
{
|
|
if (holdingObj == interaction.GetGameObject())
|
|
{
|
|
EnumEventSystem.Global.Send(TriggerEnum.PointerUp, interaction);
|
|
holdingObj = null;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 单例必须的代码
|
|
|
|
private EventSystemEx()
|
|
{
|
|
}
|
|
|
|
public override void OnSingletonInit()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
public enum TriggerEnum
|
|
{
|
|
PointerEnter,
|
|
PointerExit,
|
|
PointerDown,
|
|
PointerUp
|
|
}
|
|
} |