支持除鼠标以外其他输入方式的Point位置获取,比如VR项目

This commit is contained in:
Ambitroc
2023-03-10 10:41:11 +08:00
parent 6f69af3945
commit 99b3d24366
2 changed files with 7 additions and 5 deletions

View File

@@ -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<PointerEventData, BaseGraph> m_OnPointerClick;
protected Action<PointerEventData, BaseGraph> 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);
}