protected virtual void LateUpdate() { if (!m_IsVisible || !NRInput.ReticleVisualActive) { SwitchReticleState(ReticleState.Hide); return; } var result = m_Raycaster.FirstRaycastResult(); var points = m_Raycaster.BreakPoints; var pointCount = points.Count; if (result.isValid) { SwitchReticleState(ReticleState.Hover); transform.position = result.worldPosition; transform.rotation = Quaternion.LookRotation(result.worldNormal, m_Raycaster.transform.forward); m_HitTarget = result.gameObject; } else { SwitchReticleState(ReticleState.Normal); if (pointCount != 0) { transform.localPosition = Vector3.forward * defaultDistance; transform.localRotation = Quaternion.identity; } m_HitTarget = null; } if (m_CameraRoot) { transform.localScale = Vector3.one * reticleSizeRatio * (transform.position - m_CameraRoot.transform.position).magnitude; } }
protected virtual void LateUpdate() { if (!NRInput.LaserVisualActive) { m_LineRenderer.enabled = false; return; } var result = m_Raycaster.FirstRaycastResult(); if (showOnHitOnly && !result.isValid) { m_LineRenderer.enabled = false; return; } var points = m_Raycaster.BreakPoints; var pointCount = points.Count; if (pointCount < 2) { return; } m_LineRenderer.enabled = true; m_LineRenderer.useWorldSpace = false; //var startPoint = transform.TransformPoint(0f, 0f, m_Raycaster.NearDistance); var startPoint = transform.TransformPoint(0f, -m_Raycaster.NearDistance, 0f); //var endPoint = result.isValid ? points[pointCount - 1] // : (m_Raycaster.transform.position + m_Raycaster.transform.forward * defaultDistance); var endPoint = result.isValid ? points[pointCount - 1] : (m_Raycaster.transform.position + -m_Raycaster.transform.up * defaultDistance); if (pointCount == 2) { #if UNITY_5_6_OR_NEWER m_LineRenderer.positionCount = 2; #elif UNITY_5_5_OR_NEWER lineRenderer.numPositions = 2; #else lineRenderer.SetVertexCount(2); #endif m_LineRenderer.SetPosition(0, transform.InverseTransformPoint(startPoint)); m_LineRenderer.SetPosition(1, transform.InverseTransformPoint(endPoint)); } }