EventSystem扩展
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user