Deselect the current selected GameObject if the currently pointed-at GameObject is different.
protected void DeselectIfSelectionChanged(GameObject currentOverGo, BaseEventData pointerEvent) { if (ExecuteEvents.GetEventHandler<ISelectHandler>(currentOverGo) != base.eventSystem.currentSelectedGameObject) { base.eventSystem.SetSelectedGameObject(null, pointerEvent); } }