From 99b3d243663f6c61acefcfee1f3841ac6bf0c4b4 Mon Sep 17 00:00:00 2001
From: Ambitroc <18574152056@163.com>
Date: Fri, 10 Mar 2023 10:41:11 +0800
Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=99=A4=E9=BC=A0=E6=A0=87?=
=?UTF-8?q?=E4=BB=A5=E5=A4=96=E5=85=B6=E4=BB=96=E8=BE=93=E5=85=A5=E6=96=B9?=
=?UTF-8?q?=E5=BC=8F=E7=9A=84Point=E4=BD=8D=E7=BD=AE=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=EF=BC=8C=E6=AF=94=E5=A6=82VR=E9=A1=B9=E7=9B=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Runtime/Internal/BaseGraph.API.cs | 3 ++-
Runtime/Internal/BaseGraph.cs | 9 +++++----
2 files changed, 7 insertions(+), 5 deletions(-)
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 @@ namespace XCharts.Runtime
/// 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 @@ namespace XCharts.Runtime
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 @@ namespace XCharts.Runtime
{
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 @@ namespace XCharts.Runtime
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);
}