Detect object being deselected

Hello! On my course into editor scripts, I stumbled into this situation - how do I know if my GameObject was deselected? I’m doing some stuff in its editor script which deals with some other gameObjects, which, in turn, needs to be deactivated if the said gameObject is deselected.

Problem is, I’ve no idea of any callbacks/messages that notifies the script of the deselection…

Anybody have a solution?

Regards.

In the Custom Inspector you can use the OnDisable() method to perform your task as it is called when your GameObject is de-selected in hierarchy view.