引擎简单更新
This commit is contained in:
@@ -11,32 +11,32 @@ namespace AibisDream.Framework
|
||||
|
||||
#region 事件触发中转
|
||||
|
||||
public void OnPointerEnter(GameObject gameObject)
|
||||
public void OnPointerEnter(IInteraction interaction)
|
||||
{
|
||||
pointerOverObj = gameObject;
|
||||
EnumEventSystem.Global.Send(TriggerEnum.PointerEnter, gameObject);
|
||||
pointerOverObj = interaction.GetGameObject();
|
||||
EnumEventSystem.Global.Send(TriggerEnum.PointerEnter, interaction);
|
||||
}
|
||||
|
||||
public void OnPointerExit(GameObject gameObject)
|
||||
public void OnPointerExit(IInteraction interaction)
|
||||
{
|
||||
if (pointerOverObj == gameObject)
|
||||
if (pointerOverObj == interaction.GetGameObject())
|
||||
{
|
||||
EnumEventSystem.Global.Send(TriggerEnum.PointerExit, gameObject);
|
||||
EnumEventSystem.Global.Send(TriggerEnum.PointerExit, interaction);
|
||||
pointerOverObj = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerDown(GameObject gameObject)
|
||||
public void OnPointerDown(IInteraction interaction)
|
||||
{
|
||||
EnumEventSystem.Global.Send(TriggerEnum.PointerDown, gameObject);
|
||||
holdingObj = gameObject;
|
||||
EnumEventSystem.Global.Send(TriggerEnum.PointerDown, interaction);
|
||||
holdingObj = interaction.GetGameObject();
|
||||
}
|
||||
|
||||
public void OnPointerUp(GameObject gameObject)
|
||||
public void OnPointerUp(IInteraction interaction)
|
||||
{
|
||||
if (holdingObj == gameObject)
|
||||
if (holdingObj == interaction.GetGameObject())
|
||||
{
|
||||
EnumEventSystem.Global.Send(TriggerEnum.PointerUp, gameObject);
|
||||
EnumEventSystem.Global.Send(TriggerEnum.PointerUp, interaction);
|
||||
holdingObj = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,13 @@ namespace AibisDream.Framework
|
||||
[RequireComponent(typeof(Collider2D))]
|
||||
public class EventTriggerEx : EventTrigger
|
||||
{
|
||||
private IInteraction _interaction;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_interaction = GetComponent<IInteraction>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册事件
|
||||
/// </summary>
|
||||
@@ -68,26 +75,44 @@ namespace AibisDream.Framework
|
||||
|
||||
public override void OnPointerEnter(PointerEventData data)
|
||||
{
|
||||
EventSystemEx.Instance.OnPointerEnter(gameObject);
|
||||
EventSystemEx.Instance.OnPointerEnter(_interaction);
|
||||
base.OnPointerEnter(data);
|
||||
}
|
||||
|
||||
public override void OnPointerExit(PointerEventData data)
|
||||
{
|
||||
EventSystemEx.Instance.OnPointerExit(gameObject);
|
||||
EventSystemEx.Instance.OnPointerExit(_interaction);
|
||||
base.OnPointerExit(data);
|
||||
}
|
||||
|
||||
public override void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
EventSystemEx.Instance.OnPointerDown(gameObject);
|
||||
base.OnPointerDown(eventData);
|
||||
if (_interaction.IsAvailable)
|
||||
{
|
||||
EventSystemEx.Instance.OnPointerDown(_interaction);
|
||||
base.OnPointerDown(eventData);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
EventSystemEx.Instance.OnPointerUp(gameObject);
|
||||
base.OnPointerUp(eventData);
|
||||
if (_interaction.IsAvailable)
|
||||
{
|
||||
EventSystemEx.Instance.OnPointerUp(_interaction);
|
||||
base.OnPointerUp(eventData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IInteraction
|
||||
{
|
||||
// 判断是否激活,激活就正常显示鼠标,否则就显示禁用标志
|
||||
public bool IsActive { get; }
|
||||
|
||||
// 判断是否可用,可用就正常显示鼠标,否则就保持原有标志不变
|
||||
public bool IsAvailable { get; }
|
||||
|
||||
// 返回GameObject
|
||||
public GameObject GetGameObject();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user