void CheckForInteractable() { Ray _ray = new Ray(m_cam.transform.position, m_cam.transform.forward); RaycastHit _hitInfo; bool _hitSomething = Physics.SphereCast(_ray, raySphereRadius, out _hitInfo, rayDistance, interactableLayer); if (_hitSomething) { InteractableBase _interactable = _hitInfo.transform.GetComponent <InteractableBase>(); if (_interactable != null) { if (interactionData.IsEmpty()) { interactionData.Interactable = _interactable; uiPanel.SetTooltip(_interactable.TooltipMessage); } else { if (!interactionData.IsSameInteractable(_interactable)) { interactionData.Interactable = _interactable; uiPanel.SetTooltip(_interactable.TooltipMessage); } } } } else { uiPanel.ResetUI(); interactionData.ResetData(); } Debug.DrawRay(_ray.origin, _ray.direction * rayDistance, _hitSomething ? Color.green : Color.red); }