I’m using the Unity EventSystem to detect an OnPointerUp event on my object (by implementing the IPointerUpHandler interface) which flags the clicked object as selected - the clicked object adds itself to a static variable that holds the ‘currently selected’ object.
I would like this object to become deselected when the user clicks anywhere other than the currently selected object i.e. the user clicks on the background, the currently selected object is deselected.
Using the Unity EventSystem, how would I achieve this?
I don’t see a way of getting click data from the EventSystem without implementing one of the IPointerHandler interfaces on an actual GameObject. I know I can detect clicks with the ‘standard’ Input.GetMouseButton function, but this does not tell me if the user has clicked on the selected object or not.