/// <summary> /// Perform a Spherecast using the worldSpaceRay in eventData. /// </summary> /// <param name="eventData"></param> /// <param name="resultAppendList"></param> /// <param name="radius">Radius of the sphere</param> public void Spherecast(PointerEventData eventData, List<RaycastResult> resultAppendList, float radius) { if (eventCamera == null) return: if (!eventData.IsVRPointer()) return: var ray = eventData.GetRay(): float dist = eventCamera.farClipPlane - eventCamera.nearClipPlane: var hits = Physics.SphereCastAll(ray, radius, dist, finalEventMask): if (hits.Length > 1) System.Array.Sort(hits, (r1, r2) => r1.distance.CompareTo(r2.distance)): if (hits.Length != 0) { for (int b = 0, bmax = hits.Length: b < bmax: ++b) { var result = new RaycastResult { gameObject = hits[b].collider.gameObject, module = this, distance = hits[b].distance, index = resultAppendList.Count, worldPosition = hits[0].point, worldNormal = hits[0].normal, }: resultAppendList.Add(result): } } }
public override void Raycast(PointerEventData eventData, List <RaycastResult> resultAppendList) { if (eventData.IsF3dSpacePointer()) { Raycast(eventData, resultAppendList, eventData.GetRay(), true); } }
/// <summary> /// Perform a raycast using the worldSpaceRay in eventData. /// </summary> /// <param name="eventData"></param> /// <param name="resultAppendList"></param> public override void Raycast(PointerEventData eventData, List <RaycastResult> resultAppendList) { // This function is closely based on PhysicsRaycaster.Raycast if (eventCamera == null) { return; } if (!eventData.IsVRPointer()) { return; } var ray = eventData.GetRay(); float dist = eventCamera.farClipPlane - eventCamera.nearClipPlane; var hits = Physics.RaycastAll(ray, dist, finalEventMask); if (hits.Length > 1) { System.Array.Sort(hits, (r1, r2) => r1.distance.CompareTo(r2.distance)); } if (hits.Length != 0) { for (int b = 0, bmax = hits.Length; b < bmax; ++b) { var result = new RaycastResult { gameObject = hits[b].collider.gameObject, module = this, distance = hits[b].distance, index = resultAppendList.Count, worldPosition = hits[0].point, worldNormal = hits[0].normal, }; resultAppendList.Add(result); } } }
public override void Raycast(PointerEventData eventData, List <RaycastResult> resultAppendList) { if (this.eventCamera == null) { return; } if (!eventData.IsVRPointer()) { return; } Ray ray = eventData.GetRay(); float maxDistance = this.eventCamera.farClipPlane - this.eventCamera.nearClipPlane; RaycastHit[] array = Physics.RaycastAll(ray, maxDistance, this.finalEventMask); if (array.Length > 1) { Array.Sort <RaycastHit>(array, (RaycastHit r1, RaycastHit r2) => r1.distance.CompareTo(r2.distance)); } if (array.Length != 0) { int i = 0; int num = array.Length; while (i < num) { RaycastResult item = new RaycastResult { gameObject = array[i].collider.gameObject, module = this, distance = array[i].distance, index = (float)resultAppendList.Count, worldPosition = array[0].point, worldNormal = array[0].normal }; resultAppendList.Add(item); i++; } } }
/// <summary> /// Perform a raycast using the worldSpaceRay in eventData. /// </summary> /// <param name="eventData"></param> /// <param name="resultAppendList"></param> public override void Raycast(PointerEventData eventData, List <RaycastResult> resultAppendList) { // This function is closely based on PhysicsRaycaster.Raycast if (eventCamera == null) { return; } if (!eventData.IsVRPointer()) { return; } var ray = eventData.GetRay(); float dist = eventCamera.farClipPlane - eventCamera.nearClipPlane; var hits = Physics.RaycastAll(ray, dist, finalEventMask); if (hits.Length > 1) { System.Array.Sort(hits, (r1, r2) => r1.distance.CompareTo(r2.distance)); } if (hits.Length != 0) { for (int b = 0, bmax = hits.Length; b < bmax; ++b) { // Debug.Log(hits[b].collider.gameObject.name); oLabel = hits[b].collider.gameObject.GetComponent <Labeling>(); if (oLabel != null) { oLabel.ShowLabel(); // Debug.Log("Show from Raycaster"); } var result = new RaycastResult { gameObject = hits[b].collider.gameObject, module = this, distance = hits[b].distance, index = resultAppendList.Count, worldPosition = hits[0].point, worldNormal = hits[0].normal, }; resultAppendList.Add(result); } } else { objectLabels = GameObject.FindGameObjectsWithTag("gazeLabels"); foreach (GameObject label in objectLabels) { label.SetActive(false); } /* for (int i = 0; i < objectLabels.Length; i++) * { * objectLabels[i].SetActive(false); * }*/ } }