78 lines
1.9 KiB
C#
78 lines
1.9 KiB
C#
using AibisDream.Kit;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.Framework
|
|
{
|
|
public class EventSystemEx : SingletonBase<EventSystemEx>
|
|
{
|
|
#region 状态
|
|
|
|
public bool isLocked;
|
|
|
|
#endregion
|
|
|
|
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 事件注册
|
|
|
|
public override void OnSingletonInit()
|
|
{
|
|
EnumEventSystem.Global.Register(EventEnum.OpenScreen, () => isLocked = true);
|
|
EnumEventSystem.Global.Register(EventEnum.CloseScreen, () => isLocked = false);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 单例必须的代码
|
|
|
|
private EventSystemEx()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
public enum TriggerEnum
|
|
{
|
|
PointerEnter,
|
|
PointerExit,
|
|
PointerDown,
|
|
PointerUp
|
|
}
|
|
} |