private void MousePick(RaycastHitHandler handler) { Ray ray = camera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { handler(hit); } }
private void Update() { RayIndicator.transform.position = _controller.Position; RayIndicator.transform.rotation = _controller.Orientation; RaycastHit hit; RaycastHitHandler handler = null; if (Physics.Raycast(_controller.Position, _controller.Orientation * Vector3.forward, out hit)) { handler = hit.collider.gameObject.GetComponent <RaycastHitHandler>(); } try { if (handler != null) { handler.OnPoint(_controller.TriggerValue > .1f); if (!System.Object.ReferenceEquals(lastHovered, handler)) { if (lastHovered != null) { lastHovered.OnPointLeave(_controller.TriggerValue > .1f); } handler.OnPointEnter(_controller.TriggerValue > .1f); } } else { if (lastHovered != null) { lastHovered.OnPointLeave(_controller.TriggerValue > .1f); } } } catch (System.NotImplementedException e) { Debug.LogError(e); } lastHovered = handler; }