Unity Inspector - Detect when reference is set

Hello everyone!
Is there a way, in Edit Mode, to detect when some object is dragged into a field or set?

Let’s say I have a script in the inspector, in this script there’s a field “Test”… When I specify a GameObject to this field, it will show some description.
5237681--522686--upload_2019-12-2_15-43-28.png

Is there a way, maybe some event to subscribe to, that I can “listen” to the changes in this field? In Edit Mode, not Play mode.

Thank you in advance!

@shadowlord1

You can detect object field changes with editor script.

1 Like

Thank you very much @eses !
Editor script is the way to go! :slight_smile:

@shadowlord1

BTW then there is also OnValidate method, which will react to any field changes so you can run some code.

2 Likes

Oh , that’s perfect!
It’s much easier when we know what to search for.
Thank you again!