Get your own script by dragging a gameobject to a field of a custom window

I am creating a custom window in Unity.
And I want the window to have fields to be able to drag gameobjects from the scene, to get a script of my own that I have created and it is attached to the gameobject that I want to drag into the field of the custom window.

I tried with: “myScript = EditorGUILayout.ObjectField(myScript, typeof(myScript), false) as myScript;”

But it seems that it only works for dragging prefabs to the window fields, and not scene objects that have this script.

How can I get what I need? Is what I want possible?

Greetings

Take a look at the docs and what the boolean you’re passing false into does.

3 Likes

Thanks!!!