Skip to content

Commit

Permalink
Merge pull request #248 from Ambitroc/master
Browse files Browse the repository at this point in the history
支持除鼠标以外其他输入方式的Point位置获取,比如VR项目
  • Loading branch information
monitor1394 authored Mar 10, 2023
2 parents 6f69af3 + 99b3d24 commit adbd88c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Runtime/Internal/BaseGraph.API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public partial class BaseGraph
/// Whether the mouse pointer is in the chart.
/// |鼠标是否在图表内。
/// </summary>
public bool isPointerInChart { get; protected set; }
public bool isPointerInChart
{ get { return m_PointerEventData != null; } }
/// <summary>
/// 警告信息。
/// </summary>
Expand Down
9 changes: 5 additions & 4 deletions Runtime/Internal/BaseGraph.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
Expand Down Expand Up @@ -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<PointerEventData, BaseGraph> m_OnPointerClick;
protected Action<PointerEventData, BaseGraph> m_OnPointerDown;
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit adbd88c

Please sign in to comment.