public void OnHoldHandler() { Ray ray = cam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit)) { IClickable clickable = hit.transform.GetComponent <IClickable>(); clickable?.OnHold(); // Do something with the object that was hit by the raycast. } }