Fixed bug where poi selection triggered by the reticule would not work when the detailspanel was between crosshair and poi

This commit is contained in:
2018-09-28 16:01:21 +02:00
parent 6c96d5434d
commit fbb247b8a2

View File

@@ -28,7 +28,7 @@ namespace RothenburgAR.UI
}
}
public void DoRaycast(Vector2 screenPoint)
public void DoRaycast(Vector2 screenPoint, bool denyBlockedHits = true)
{
RaycastHit hitInfo = new RaycastHit();
Ray ray = Camera.main.ScreenPointToRay(screenPoint);
@@ -39,28 +39,28 @@ namespace RothenburgAR.UI
GameObject go = hitInfo.transform.gameObject;
var bb = go.GetComponent<PoiRaycastReceiverBehaviour>();
if (bb == null) return;
if (AbortBecauseDetailsPanelHit(screenPoint)) return;
if (denyBlockedHits && DenyBlockedHits(screenPoint)) return;
bb.OnClick.Invoke();
}
private bool AbortBecauseDetailsPanelHit(Vector2 screenPoint)
private bool DenyBlockedHits(Vector2 screenPoint)
{
if (!UIManager.Instance.IsARViewVisible) return true;
var pointer = new UnityEngine.EventSystems.PointerEventData(UnityEngine.EventSystems.EventSystem.current);
pointer.position = screenPoint;
List<UnityEngine.EventSystems.RaycastResult> results = new List<UnityEngine.EventSystems.RaycastResult>();
var _raycaster = UIManager.Instance.ARViewBehaviour.GetComponent<UnityEngine.UI.GraphicRaycaster>();
_raycaster.Raycast(pointer, results);
return results.Count != 0;
}
public void ActivateCrosshairs()
{
Vector2 center = new Vector2(Camera.main.pixelWidth / 2, Camera.main.pixelHeight / 2);
DoRaycast(center);
DoRaycast(center, false);
}
private List<Vector2> GatherScreenPoints()