Skip to content

Commit

Permalink
Implemented IsPointerOverGameObject.
Browse files Browse the repository at this point in the history
  • Loading branch information
valyard committed Jan 27, 2017
1 parent ebf8bdf commit cd98e8b
Showing 1 changed file with 29 additions and 11 deletions.
Expand Up @@ -133,7 +133,8 @@ public override void Process()

public override bool IsPointerOverGameObject(int pointerId)
{
return base.IsPointerOverGameObject(pointerId);
if (ui != null) return ui.IsPointerOverGameObject(pointerId);
return false;
}

public override bool ShouldActivateModule()
Expand Down Expand Up @@ -214,16 +215,25 @@ public UIStandardInputModule(TouchScriptInputModule input)
this.input = input;
}

#region Unchanged
#region Unchanged from PointerInputModule

private int m_ConsecutiveMoveCount = 0;
private Vector2 m_LastMoveVector;
private float m_PrevActionTime;

private Dictionary<int, PointerEventData> m_PointerData = new Dictionary<int, PointerEventData>();

public bool IsPointerOverGameObject(int pointerId)
{
var lastPointer = GetLastPointerEventData(pointerId);
if (lastPointer != null)
return lastPointer.pointerEnter != null;
return false;
}

protected bool GetPointerData(int id, out PointerEventData data, bool create)
{
Debug.Log(id);
if (!m_PointerData.TryGetValue(id, out data) && create)
{
data = new PointerEventData(input.eventSystem)
Expand All @@ -246,6 +256,13 @@ protected void DeselectIfSelectionChanged(GameObject currentOverGo, BaseEventDat
input.eventSystem.SetSelectedGameObject(null, pointerEvent);
}

protected PointerEventData GetLastPointerEventData(int id)
{
PointerEventData data;
GetPointerData(id, out data, false);
return data;
}

private static bool ShouldStartDrag(Vector2 pressPos, Vector2 currentPos, float threshold, bool useDragThreshold)
{
if (!useDragThreshold)
Expand Down Expand Up @@ -375,19 +392,20 @@ protected void RemovePointerData(int id)
m_PointerData.Remove(id);
}

private void convertRaycast(RaycastHitUI old, ref RaycastResult current)
{
current.module = old.Raycaster;
current.gameObject = old.GameObject;
current.depth = old.Depth;
current.index = old.GraphicIndex;
current.sortingLayer = old.SortingLayer;
current.sortingOrder = old.SortingOrder;
}

#endregion

#region Event processors

private void convertRaycast(RaycastHitUI old, ref RaycastResult current)
{
current.module = old.Raycaster;
current.gameObject = old.GameObject;
current.depth = old.Depth;
current.index = old.GraphicIndex;
current.sortingLayer = old.SortingLayer;
current.sortingOrder = old.SortingOrder;
}
public virtual void ProcessUpdated(object sender, PointerEventArgs pointerEventArgs)
{
var pointers = pointerEventArgs.Pointers;
Expand Down

0 comments on commit cd98e8b

Please sign in to comment.