mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-26 10:50:08 +00:00
Merge pull request #248 from Ambitroc/master
支持除鼠标以外其他输入方式的Point位置获取,比如VR项目
This commit is contained in:
@@ -51,7 +51,8 @@ namespace XCharts.Runtime
|
|||||||
/// Whether the mouse pointer is in the chart.
|
/// Whether the mouse pointer is in the chart.
|
||||||
/// |鼠标是否在图表内。
|
/// |鼠标是否在图表内。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool isPointerInChart { get; protected set; }
|
public bool isPointerInChart
|
||||||
|
{ get { return m_PointerEventData != null; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 警告信息。
|
/// 警告信息。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@@ -35,6 +35,7 @@ namespace XCharts.Runtime
|
|||||||
protected bool m_PainerDirty = false;
|
protected bool m_PainerDirty = false;
|
||||||
protected bool m_IsOnValidate = false;
|
protected bool m_IsOnValidate = false;
|
||||||
protected Vector3 m_LastLocalPosition;
|
protected Vector3 m_LastLocalPosition;
|
||||||
|
protected PointerEventData m_PointerEventData;
|
||||||
|
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnPointerClick;
|
protected Action<PointerEventData, BaseGraph> m_OnPointerClick;
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnPointerDown;
|
protected Action<PointerEventData, BaseGraph> m_OnPointerDown;
|
||||||
@@ -209,7 +210,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
if (!isPointerInChart) return;
|
if (!isPointerInChart) return;
|
||||||
if (canvas == null) return;
|
if (canvas == null) return;
|
||||||
Vector2 mousePos = Input.mousePosition;
|
Vector2 mousePos = m_PointerEventData.position;
|
||||||
Vector2 local;
|
Vector2 local;
|
||||||
if (!ScreenPointToChartPoint(mousePos, out local))
|
if (!ScreenPointToChartPoint(mousePos, out local))
|
||||||
{
|
{
|
||||||
@@ -278,13 +279,13 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public virtual void OnPointerEnter(PointerEventData eventData)
|
public virtual void OnPointerEnter(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
isPointerInChart = true;
|
m_PointerEventData = eventData;
|
||||||
if (m_OnPointerEnter != null) m_OnPointerEnter(eventData, this);
|
if (m_OnPointerEnter != null) m_OnPointerEnter(eventData, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnPointerExit(PointerEventData eventData)
|
public virtual void OnPointerExit(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
isPointerInChart = false;
|
m_PointerEventData = null;
|
||||||
if (m_OnPointerExit != null) m_OnPointerExit(eventData, this);
|
if (m_OnPointerExit != null) m_OnPointerExit(eventData, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user