Is there a way to make an editor button that will select prefab objects?
I made a simple editor window that lists prefab objects and their properties in a table format to save me some clicks for editing values. I want to be able to click a button for a listed object that will then select the prefab.
Unfortunately the Selection class only returns the current selections and I can’t find any methods to actually set the selection:
Any ideas?
Also on this custom editor subject, when I change a property value using my editor window, the prefab updates fine and all is well. However, when I quit and re-open that value is lost. Only property values that I change in the inspector stick between Unity sessions.
What do I need to do to make values in a custom editor stick?
Ok, I got this one figured out. Employing EditorUtility.SetDirty did the trick:
I still need some help on changing selections via a custom editor.
You can make a button that instantiates a prefab so you can drag it around in scene.
Also, I hope this helps:
Object found_asset = EditorUtility.FindAsset(asset_path, typeof(Object));
if (found_asset != null)
{
Selection.activeObject = found_asset;
}
Ah, thanks for the response gnoblin. You answered my question in the snippet. I didn’t think to try actually setting the Selection.activeObject variable. The docs only say it Returns the active object so I assumed it only would be read-only… This probably means other class variables are actually settable, too.
Well now I know, thanks!
-Andrew