diff --git a/Runtime/Internal/BaseGraph.API.cs b/Runtime/Internal/BaseGraph.API.cs index d15276ff..499c24b1 100644 --- a/Runtime/Internal/BaseGraph.API.cs +++ b/Runtime/Internal/BaseGraph.API.cs @@ -51,7 +51,8 @@ public partial class BaseGraph /// Whether the mouse pointer is in the chart. /// |鼠标是否在图表内。 /// - public bool isPointerInChart { get; protected set; } + public bool isPointerInChart + { get { return m_PointerEventData != null; } } /// /// 警告信息。 /// diff --git a/Runtime/Internal/BaseGraph.cs b/Runtime/Internal/BaseGraph.cs index b9ffb696..8e1a8bca 100644 --- a/Runtime/Internal/BaseGraph.cs +++ b/Runtime/Internal/BaseGraph.cs @@ -1,4 +1,4 @@ -using System; +using System; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; @@ -35,6 +35,7 @@ public partial class BaseGraph : MaskableGraphic, IPointerDownHandler, IPointerU protected bool m_PainerDirty = false; protected bool m_IsOnValidate = false; protected Vector3 m_LastLocalPosition; + protected PointerEventData m_PointerEventData; protected Action m_OnPointerClick; protected Action m_OnPointerDown; @@ -209,7 +210,7 @@ private void CheckPointerPos() { if (!isPointerInChart) return; if (canvas == null) return; - Vector2 mousePos = Input.mousePosition; + Vector2 mousePos = m_PointerEventData.position; Vector2 local; if (!ScreenPointToChartPoint(mousePos, out local)) { @@ -278,13 +279,13 @@ public virtual void OnPointerUp(PointerEventData eventData) public virtual void OnPointerEnter(PointerEventData eventData) { - isPointerInChart = true; + m_PointerEventData = eventData; if (m_OnPointerEnter != null) m_OnPointerEnter(eventData, this); } public virtual void OnPointerExit(PointerEventData eventData) { - isPointerInChart = false; + m_PointerEventData = null; if (m_OnPointerExit != null) m_OnPointerExit(eventData, this); }