How do I create a gameobject field in a custom editor?

Hello,
I’m trying to add a gameobject field to a custom editor. I’ve tried with EditorGUILayout.ObjectField, but it doesn’t work. Can you please help me?

@$$anonymous$$ I’ve been trying to figure this out too, and I finally feel I know how to go about this.

You can use EditorGUILayout.ObjectField(), but you must cast it into a game object.

For example,

exampleScript.exampleGO = (GameObject)EditorGUILayout.ObjectField("Example GO", exampleScript.exampleGO, typeOf(GameObject), true);

I hope this helps