- Home /
EditorGUILayout.ObjectField displays empty list in Object Picker Window
In Unity 3.5.6 and earlier, I was able to use the ObjectField control to pick assets of a custom type. I created a TextureAtlas class that inherited from Scriptable. You could select one of these assets by clicking on the ObjectField control and choosing the atlas asset from the list in the Object picker.
In Unity 4, this functionality appears to have gone away. Now when the object picker window pops up, it is empty (except for the choice of "None"). It works when I use a generic type like "Object", but not on my custom class "TextureAtlas".
Is this a bug in Unity 4?
Code:
TextureAtlas selectedAtlas;
TextureAtlas newAtlas = (TextureAtlas)EditorGUILayout.ObjectField(selectedAtlas, typeof(TextureAtlas), false);
I don't oft make things derived from ScriptableObject, but you may need to ensure that the derived class (TextureAtlas) is set as serializable.
Thanks for the answer, but that didn't make it appear in the list.
I am having the same problem, did you come up with any solution?
Sort of, but it didn't solve the problem directly. Ins$$anonymous$$d, in the inspector in the OnEnable function, I gather a list of resources of the type I'm looking for. In the OnInspectorGUI function I display those resources in a popup list for the user to choose. I keep a list of names and a list of object references. The user sees the names, but behind the scenes I store the object reference based on the index that is selected.
Yeah, i was afraid that it was the only solution. But it is so unfair because built in object fields have this functionality! So sad =(
Your answer
![](https://koobas.hobune.stream/wayback/20220613085234im_/https://answers.unity.com/themes/thub/images/avi.jpg)