- Home /
Editor scripting, select a field
Hi, im making my first editor script. I want to make an my fields selectable, and when it is active i want a pop up window to show up.
Ive been trying to use Selection.activeGameObject like so
for(com in target.gameObjectsToModify)
{
com=EditorGUILayout.ObjectField(com,GameObject,false,options);
if(Selection.activeGameObject==com)//Create popup
}
This doesnt work, as i tried printing from the if statement. What is the proper way to get the selection of the field?
I made another script that extends EditorWindow for the pop up. Currently the popup never shows up ( im not using any conditionals currently). Lets say it does work, how can i link it to that if statement and create that popup when the field is selected?
You want that if you select a gameObject that is listed a popup appears?
I want it so when you click the Object field the popup appears (the object field lists all my modifiable gameobjects).
@Scroodge$$anonymous$$ The code i have above is an Editor script, im not sure how to make the popup in the Editor script, so i made a seperate EditorWindow script. This is probly not the way to go about it...but im really unsure how to do what i proposed.
Answer by ScroodgeM · Aug 14, 2012 at 08:31 PM
Editor script executes only when object that this editor is created for is becomes selected
so, you should use EditorWindow to monitor selection changing using
http://docs.unity3d.com/Documentation/ScriptReference/EditorWindow.OnSelectionChange.html
and make whatever you want in this method.
Ok, thats what i was looking for. Hopefully i can integrate it with my Editor script. Thanks
@Scroodge Tho only probly with this is that you need to click the actual object. I want to click the Field and have the window popup.
what's the problem though? if you need field me clickable just use button with field style, then it will look like a field but can be clickable...
@Scroodge$$anonymous$$ Oh i was unaware of that solution. Ok that helps me a ton, thank you! Sorry for my ignorance in this realm, first editor/editorWindow scripts. I appreciate the help a bunch. Thanks again.