private HitTest.ObjectHitResult doHit(RaycastHit raycastHit, out ITouchHit hit) { hit = TouchHitFactory.Instance.GetTouchHit(raycastHit); var hitTests = raycastHit.transform.GetComponents <HitTest>(); if (hitTests.Length == 0) { return(HitTest.ObjectHitResult.Hit); } var hitResult = HitTest.ObjectHitResult.Hit; foreach (var test in hitTests) { if (!test.enabled) { continue; } hitResult = test.IsHit(hit); if (hitResult == HitTest.ObjectHitResult.Miss || hitResult == HitTest.ObjectHitResult.Discard) { break; } } return(hitResult); }
/// <inheritdoc /> public override LayerHitResult Hit(Vector2 position, out ITouchHit hit) { if (base.Hit(position, out hit) == LayerHitResult.Miss) { return(LayerHitResult.Miss); } hit = TouchHitFactory.Instance.GetTouchHit(transform); var hitTests = transform.GetComponents <HitTest>(); if (hitTests.Length == 0) { return(LayerHitResult.Hit); } foreach (var test in hitTests) { if (!test.enabled) { continue; } var hitResult = test.IsHit(hit); if (hitResult == HitTest.ObjectHitResult.Miss || hitResult == HitTest.ObjectHitResult.Discard) { return(LayerHitResult.Miss); } } return(LayerHitResult.Hit); }
private HitTest.ObjectHitResult doHit(RaycastHit raycastHit, out ITouchHit hit) { hit = TouchHitFactory.Instance.GetTouchHit(raycastHit); raycastHit.transform.GetComponents(tmpHitTestList); var count = tmpHitTestList.Count; if (tmpHitTestList.Count == 0) { return(HitTest.ObjectHitResult.Hit); } var hitResult = HitTest.ObjectHitResult.Hit; for (var i = 0; i < count; i++) { var test = tmpHitTestList[i]; if (!test.enabled) { continue; } hitResult = test.IsHit(hit); if (hitResult == HitTest.ObjectHitResult.Miss || hitResult == HitTest.ObjectHitResult.Discard) { break; } } return(hitResult); }
/// <inheritdoc /> public bool GetHitTarget(Vector2 position, out ITouchHit hit, out TouchLayer layer) { hit = null; layer = null; var count = layers.Count; for (var i = 0; i < count; i++) { var touchLayer = layers[i]; if (touchLayer == null) { continue; } ITouchHit _hit; if (touchLayer.Hit(position, out _hit) == TouchLayer.LayerHitResult.Hit) { hit = _hit; layer = touchLayer; return(true); } } return(false); }
protected override LayerHitResult beginTouch(ITouch touch, out ITouchHit hit) { hit = null; if (enabled == false || gameObject.activeInHierarchy == false) return LayerHitResult.Miss; var result = movie.BeginTouch(touch.Id, touch.Position.x, touch.Position.y); return (LayerHitResult)result; }
internal void INTERNAL_Reset() { TouchHitFactory.Instance.ReleaseTouchHit(hit); hit = null; Target = null; Layer = null; Tags = null; properties.Clear(); }
/// <summary> /// Checks if a point in screen coordinates hits something in this layer. /// </summary> /// <param name="position">Position in screen coordinates.</param> /// <param name="hit">Hit result.</param> /// <returns><see cref="LayerHitResult.Hit"/>, if an object is hit, <see cref="LayerHitResult.Miss"/> or <see cref="LayerHitResult.Error"/> otherwise.</returns> public virtual LayerHitResult Hit(Vector2 position, out ITouchHit hit) { hit = null; if (enabled == false || gameObject.activeInHierarchy == false) { return(LayerHitResult.Miss); } return(LayerHitResult.Error); }
/// <inheritdoc /> public override LayerHitResult Hit(Vector2 position, out ITouchHit hit) { if (base.Hit(position, out hit) == LayerHitResult.Miss) return LayerHitResult.Miss; if (_camera == null) return LayerHitResult.Error; if (_camera.enabled == false || _camera.gameObject.activeInHierarchy == false) return LayerHitResult.Miss; if (!_camera.pixelRect.Contains(position)) return LayerHitResult.Miss; var ray = _camera.ScreenPointToRay(position); return castRay(ray, out hit); }
protected override LayerHitResult beginTouch(ITouch touch, out ITouchHit hit) { hit = null; if (enabled == false || gameObject.activeInHierarchy == false) { return(LayerHitResult.Miss); } var result = movie.BeginTouch(touch.Id, touch.Position.x, touch.Position.y); return((LayerHitResult)result); }
/// <summary> /// Gets result of casting a ray from specific screen position. /// </summary> /// <param name="position">The position.</param> /// <param name="hit">Raycast result.</param> /// <returns>true if ray hits gesture's target; otherwise, false.</returns> public virtual bool GetTargetHitResult(Vector2 position, out ITouchHit hit) { TouchLayer layer = null; if (!touchManager.GetHitTarget(position, out hit, out layer)) { return(false); } if (cachedTransform == hit.Transform || hit.Transform.IsChildOf(cachedTransform)) { return(true); } return(false); }
/// <inheritdoc /> public void ReleaseTouchHit(ITouchHit value) { if (value is TouchHit3D) { touchHit3DPool.Release(value as TouchHit3D); } else if (value is TouchHit2D) { touchHit2DPool.Release(value as TouchHit2D); } else if (value is TouchHit) { touchHitPool.Release(value as TouchHit); } }
private HitTest.ObjectHitResult doHit(RaycastHit2D raycastHit, out ITouchHit hit) { hit = TouchHitFactory.Instance.GetTouchHit(raycastHit); var hitTests = raycastHit.transform.GetComponents<HitTest>(); if (hitTests.Length == 0) return HitTest.ObjectHitResult.Hit; var hitResult = HitTest.ObjectHitResult.Hit; foreach (var test in hitTests) { if (!test.enabled) continue; hitResult = test.IsHit(hit); if (hitResult == HitTest.ObjectHitResult.Miss || hitResult == HitTest.ObjectHitResult.Discard) break; } return hitResult; }
/// <inheritdoc /> protected override LayerHitResult castRay(Ray ray, out ITouchHit hit) { hit = null; var raycastHits = Physics.RaycastAll(ray, float.PositiveInfinity, LayerMask); if (raycastHits.Length == 0) { return(LayerHitResult.Miss); } if (raycastHits.Length > 1) { sortHits(raycastHits); RaycastHit raycastHit = default(RaycastHit); var i = 0; while (i < sortedHits.Count) { raycastHit = sortedHits[i]; switch (doHit(raycastHit, out hit)) { case HitTest.ObjectHitResult.Hit: return(LayerHitResult.Hit); case HitTest.ObjectHitResult.Discard: return(LayerHitResult.Miss); } i++; } } else { switch (doHit(raycastHits[0], out hit)) { case HitTest.ObjectHitResult.Hit: return(LayerHitResult.Hit); case HitTest.ObjectHitResult.Error: return(LayerHitResult.Error); default: return(LayerHitResult.Miss); } } return(LayerHitResult.Miss); }
private HitTest.ObjectHitResult doHit(RaycastHit raycastHit, out ITouchHit hit) { hit = TouchHitFactory.Instance.GetTouchHit(raycastHit); raycastHit.transform.GetComponents(tmpHitTestList); var count = tmpHitTestList.Count; if (tmpHitTestList.Count == 0) return HitTest.ObjectHitResult.Hit; var hitResult = HitTest.ObjectHitResult.Hit; for (var i = 0; i < count; i++) { var test = tmpHitTestList[i]; if (!test.enabled) continue; hitResult = test.IsHit(hit); if (hitResult == HitTest.ObjectHitResult.Miss || hitResult == HitTest.ObjectHitResult.Discard) break; } return hitResult; }
/// <inheritdoc /> public override LayerHitResult Hit(Vector2 position, out ITouchHit hit) { if (base.Hit(position, out hit) == LayerHitResult.Miss) { return(LayerHitResult.Miss); } if (_camera != null) { if (!_camera.pixelRect.Contains(position)) { return(LayerHitResult.Miss); } } hit = TouchHitFactory.Instance.GetTouchHit(transform); transform.GetComponents(tmpHitTestList); var count = tmpHitTestList.Count; if (count == 0) { return(LayerHitResult.Hit); } for (var i = 0; i < count; i++) { var test = tmpHitTestList[i]; if (!test.enabled) { continue; } var hitResult = test.IsHit(hit); if (hitResult == HitTest.ObjectHitResult.Miss || hitResult == HitTest.ObjectHitResult.Discard) { return(LayerHitResult.Miss); } } return(LayerHitResult.Hit); }
/// <inheritdoc /> protected override LayerHitResult castRay(Ray ray, out ITouchHit hit) { hit = null; var raycastHits = Physics2D.GetRayIntersectionAll(ray, float.PositiveInfinity, LayerMask); if (raycastHits.Length == 0) return LayerHitResult.Miss; if (raycastHits.Length > 1) { sortHits(raycastHits); RaycastHit2D raycastHit = default(RaycastHit2D); var i = 0; while (i < sortedHits.Count) { raycastHit = sortedHits[i]; switch (doHit(raycastHit, out hit)) { case HitTest.ObjectHitResult.Hit: return LayerHitResult.Hit; case HitTest.ObjectHitResult.Discard: return LayerHitResult.Miss; } i++; } } else { switch (doHit(raycastHits[0], out hit)) { case HitTest.ObjectHitResult.Hit: return LayerHitResult.Hit; case HitTest.ObjectHitResult.Error: return LayerHitResult.Error; default: return LayerHitResult.Miss; } } return LayerHitResult.Miss; }
/// <inheritdoc /> public bool GetHitTarget(Vector2 position, out ITouchHit hit, out TouchLayer layer) { hit = null; layer = null; foreach (var touchLayer in layers) { if (touchLayer == null) { continue; } ITouchHit _hit; if (touchLayer.Hit(position, out _hit) == TouchLayer.LayerHitResult.Hit) { hit = _hit; layer = touchLayer; return(true); } } return(false); }
/// <inheritdoc /> public override LayerHitResult Hit(Vector2 position, out ITouchHit hit) { if (base.Hit(position, out hit) == LayerHitResult.Miss) { return(LayerHitResult.Miss); } if (_camera == null) { return(LayerHitResult.Error); } if (_camera.enabled == false || _camera.gameObject.activeInHierarchy == false) { return(LayerHitResult.Miss); } if (!_camera.pixelRect.Contains(position)) { return(LayerHitResult.Miss); } var ray = _camera.ScreenPointToRay(position); return(castRay(ray, out hit)); }
/// <summary> /// Casts a ray from camera position. /// </summary> /// <param name="ray">The ray.</param> /// <param name="hit">Hit information if the ray has hit something.</param> /// <returns>Hit result.</returns> protected abstract LayerHitResult castRay(Ray ray, out ITouchHit hit);
/// <inheritdoc /> public override LayerHitResult Hit(Vector2 position, out ITouchHit hit) { if (base.Hit(position, out hit) == LayerHitResult.Miss) return LayerHitResult.Miss; if (_camera != null) { if (!_camera.pixelRect.Contains(position)) return LayerHitResult.Miss; } hit = TouchHitFactory.Instance.GetTouchHit(transform); transform.GetComponents(tmpHitTestList); var count = tmpHitTestList.Count; if (count == 0) return LayerHitResult.Hit; for (var i = 0; i < count; i++) { var test = tmpHitTestList[i]; if (!test.enabled) continue; var hitResult = test.IsHit(hit); if (hitResult == HitTest.ObjectHitResult.Miss || hitResult == HitTest.ObjectHitResult.Discard) return LayerHitResult.Miss; } return LayerHitResult.Hit; }
/// <summary> /// Gets result of casting a ray from gesture touch points centroid screen position. /// </summary> /// <param name="hit">Raycast result</param> /// <returns>true if ray hits gesture's target; otherwise, false.</returns> public virtual bool GetTargetHitResult(out ITouchHit hit) { return(GetTargetHitResult(ScreenPosition, out hit)); }
/// <inheritdoc /> public override ObjectHitResult IsHit(ITouchHit hit) { return(DiscardTouch ? ObjectHitResult.Discard : ObjectHitResult.Miss); }
/// <summary> /// Gets result of casting a ray from specific screen position. /// </summary> /// <param name="position">The position.</param> /// <param name="hit">Raycast result.</param> /// <returns>true if ray hits gesture's target; otherwise, false.</returns> public virtual bool GetTargetHitResult(Vector2 position, out ITouchHit hit) { TouchLayer layer = null; if (!touchManager.GetHitTarget(position, out hit, out layer)) return false; if (cachedTransform == hit.Transform || hit.Transform.IsChildOf(cachedTransform)) return true; return false; }
/// <inheritdoc /> public override ObjectHitResult IsHit(ITouchHit hit) { return DiscardTouch ? ObjectHitResult.Discard : ObjectHitResult.Miss; }
/// <summary> /// Checks if a point in screen coordinates hits something in this layer. /// </summary> /// <param name="position">Position in screen coordinates.</param> /// <param name="hit">Hit result.</param> /// <returns><see cref="LayerHitResult.Hit"/>, if an object is hit, <see cref="LayerHitResult.Miss"/> or <see cref="LayerHitResult.Error"/> otherwise.</returns> public virtual LayerHitResult Hit(Vector2 position, out ITouchHit hit) { hit = null; if (enabled == false || gameObject.activeInHierarchy == false) return LayerHitResult.Miss; return LayerHitResult.Error; }
/// <summary> /// Called when a layer is touched to query the layer if this touch hits something. /// </summary> /// <param name="touch">Touch.</param> /// <param name="hit">Hit result.</param> /// <returns><see cref="LayerHitResult.Hit"/>, if an object is hit, <see cref="LayerHitResult.Miss"/> or <see cref="LayerHitResult.Error"/> otherwise.</returns> /// <remarks>This method may also be used to update some internal state or resend this event somewhere.</remarks> protected virtual LayerHitResult beginTouch(ITouch touch, out ITouchHit hit) { var result = Hit(touch.Position, out hit); return result; }
/// <inheritdoc /> public bool GetHitTarget(Vector2 position, out ITouchHit hit) { TouchLayer layer; return GetHitTarget(position, out hit, out layer); }
/// <inheritdoc /> public bool GetHitTarget(Vector2 position, out ITouchHit hit, out TouchLayer layer) { hit = null; layer = null; var count = layers.Count; for (var i = 0; i < count; i++) { var touchLayer = layers[i]; if (touchLayer == null) continue; ITouchHit _hit; if (touchLayer.Hit(position, out _hit) == TouchLayer.LayerHitResult.Hit) { hit = _hit; layer = touchLayer; return true; } } return false; }
/// <inheritdoc /> public bool GetHitTarget(Vector2 position, out ITouchHit hit) { TouchLayer layer; return(GetHitTarget(position, out hit, out layer)); }
/// <inheritdoc /> public bool GetHitTarget(Vector2 position, out ITouchHit hit, out TouchLayer layer) { hit = null; layer = null; foreach (var touchLayer in layers) { if (touchLayer == null) continue; ITouchHit _hit; if (touchLayer.Hit(position, out _hit) == TouchLayer.LayerHitResult.Hit) { hit = _hit; layer = touchLayer; return true; } } return false; }
/// <summary> /// Determines whether a touch point hit the object. /// </summary> /// <param name="hit">Data from a raycast.</param> /// <returns><see cref="ObjectHitResult.Hit"/> if touch point hits the object, <see cref="ObjectHitResult.Miss"/> if it doesn't, <see cref="ObjectHitResult.Discard"/> if it doesn't and this touch must be ignored, Error otherwise.</returns> public virtual ObjectHitResult IsHit(ITouchHit hit) { return ObjectHitResult.Hit; }
/// <summary> /// Determines whether a touch point hit the object. /// </summary> /// <param name="hit">Data from a raycast.</param> /// <returns><see cref="ObjectHitResult.Hit"/> if touch point hits the object, <see cref="ObjectHitResult.Miss"/> if it doesn't, <see cref="ObjectHitResult.Discard"/> if it doesn't and this touch must be ignored, Error otherwise.</returns> public virtual ObjectHitResult IsHit(ITouchHit hit) { return(ObjectHitResult.Hit); }
/// <summary> /// Called when a layer is touched to query the layer if this touch hits something. /// </summary> /// <param name="touch">Touch.</param> /// <param name="hit">Hit result.</param> /// <returns><see cref="LayerHitResult.Hit"/>, if an object is hit, <see cref="LayerHitResult.Miss"/> or <see cref="LayerHitResult.Error"/> otherwise.</returns> /// <remarks>This method may also be used to update some internal state or resend this event somewhere.</remarks> protected virtual LayerHitResult beginTouch(ITouch touch, out ITouchHit hit) { var result = Hit(touch.Position, out hit); return(result); }
/// <inheritdoc /> public override LayerHitResult Hit(Vector2 position, out ITouchHit hit) { if (base.Hit(position, out hit) == LayerHitResult.Miss) return LayerHitResult.Miss; if (_camera != null) { if (!_camera.pixelRect.Contains(position)) return LayerHitResult.Miss; } hit = TouchHitFactory.Instance.GetTouchHit(transform); var hitTests = transform.GetComponents<HitTest>(); if (hitTests.Length == 0) return LayerHitResult.Hit; foreach (var test in hitTests) { if (!test.enabled) continue; var hitResult = test.IsHit(hit); if (hitResult == HitTest.ObjectHitResult.Miss || hitResult == HitTest.ObjectHitResult.Discard) return LayerHitResult.Miss; } return LayerHitResult.Hit; }
/// <summary> /// Gets result of casting a ray from gesture touch points centroid screen position. /// </summary> /// <param name="hit">Raycast result</param> /// <returns>true if ray hits gesture's target; otherwise, false.</returns> public bool GetTargetHitResult(out ITouchHit hit) { return GetTargetHitResult(ScreenPosition, out hit); }