Hi, In editor, I need to run some code on a gameobject, at the moment that gameobject is selected in the hierarchy (e.g. when the user clicks on the game object in the hierarchy). I thought the OnEnable() method was made for that, but there is obviously something I don't get since I can't get it to work. I also added the [ExecuteInEditMode] statement, but that doesn't cut it. Also tried to run code in the Update() Method, testing first if gameObject.activeSelf is true. Problem: gameObject.activeSelf is always true. I searched the forum and the doc, but I couldn't find that "OnSelected" method I need. Any ideas? ^^'
and there is also OnDrawGizmosSelected when you want to draw gizmos only when the object is selected.
activeSelf has nothing to do with editor selection, it is whether the object itself is enabled (the checkbox in the top left of the inspector), this is also valid during runtime.
Also if you need to run a function every Editor Tick (basically Update() ) you need to put in the start function EditorApplication.update += "function name"