66 lines
1.5 KiB
C#
66 lines
1.5 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(GameObject gameObject)
|
|
{
|
|
pointerOverObj = gameObject;
|
|
EnumEventSystem.Global.Send(TriggerEnum.PointerEnter, gameObject);
|
|
}
|
|
|
|
public void OnPointerExit(GameObject gameObject)
|
|
{
|
|
EnumEventSystem.Global.Send(TriggerEnum.PointerExit, gameObject);
|
|
if (pointerOverObj == gameObject)
|
|
{
|
|
pointerOverObj = null;
|
|
}
|
|
}
|
|
|
|
public void OnPointerDown(GameObject gameObject)
|
|
{
|
|
EnumEventSystem.Global.Send(TriggerEnum.PointerDown, gameObject);
|
|
holdingObj = gameObject;
|
|
}
|
|
|
|
public void OnPointerUp(GameObject gameObject)
|
|
{
|
|
EnumEventSystem.Global.Send(TriggerEnum.PointerUp, gameObject);
|
|
if (holdingObj == gameObject)
|
|
{
|
|
holdingObj = null;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 单例必须的代码
|
|
|
|
private EventSystemEx()
|
|
{
|
|
}
|
|
|
|
public override void OnSingletonInit()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
public enum TriggerEnum
|
|
{
|
|
PointerEnter,
|
|
PointerExit,
|
|
PointerDown,
|
|
PointerUp
|
|
}
|
|
} |