EditorTool, select prefabs

Hi everyone,

for one of my editor tools I need to be able to select prefabs…

GameObject res = (GameObject)EditorGUILayout.ObjectField((GameObject)obj, typeof(GameObject), false, GUILayout.Height(16));

The above code shows all assets… but is there a way to show only prefabs?

Thanks…

I don’t think you can do it with EditorGUILayour.ObjectField.

You can do it with some manual work, which I’m not sure it’s worth it in your case. You can write your custom object picker, which lists all the assets in an EditorWindow just like EditorGUILayour.ObjectField does. To list only the prefabs in the window, when iterating through all the assets, you can query if an asset is a prefab or not with PrefabUtility.GetPrefabType.