I am trying to put a game Object in my custom object field but it gives me the error
InvalidCastException: Cannot cast from source type to destination type.
The code looks like this:
Object prefab = prefabs[t];
prefabs[t] = (GameObject)EditorGUI.ObjectField(new Rect(fieldX,fieldY,position.width,20),
t.ToString(),prefab,typeof(Object),true);
fieldY + = 20;
if(prefabs[t] != null)
EditorGUI.LabelField(new Rect(0,fieldY,position.width,20),prefabs[t].name);
I am using C#.