EditorGUILayout.ObjectField cannot be changed.

I am making a custom inspector for a class. Currently I am creating a list like so.

public void DrawConnectedNodesGUI(NavigationNode nodeComponent)
    {
        if (nodeComponent == null) return;
        if (nodeComponent.connectedNodes == null)
        {
            nodeComponent.connectedNodes = new List<NavigationNode>();
        }


        EditorGUILayout.BeginVertical();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Sort Name"))
        {
            nodeComponent.SortConnectedNodesByName();
        }
        if (GUILayout.Button("Sort Distance"))
        {
            nodeComponent.SortConnectedNodesByDistance();  // Create extension method?
        }

        EditorGUILayout.EndHorizontal();

        if (GUILayout.Button("+"))
        {
            nodeComponent.connectedNodes.Add(null);
        }
        if (nodeComponent.connectedNodes.Count == 0)
        {
            GUILayout.Label("<No connections>");
        }

        for (int i = 0; i < nodeComponent.connectedNodes.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            
            var result = EditorGUILayout.ObjectField( nodeComponent.connectedNodes*, typeof(NavigationNode), true) as NavigationNode;*

if (GUILayout.Button(“-”))
{
if (result == null)
{
nodeComponent.connectedNodes.RemoveAt(i);
}
else
{
nodeComponent.DisonnectFromNode(result, true);
}
}

EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
}
While the ObjectFields are instantiated properly, I cannot edit them. Dragging and dropping a reference from the hierarchy or project folder makes the field light up like it’s about to receive, but it does not change. Picking an object from the popup menu does not work either. Objects added to the list by other methods appear in the inspector, but they cannot be edited either.

Like @Davidenishball said, you have to assign the ObjectField object to the target’s property. One more bit of info: if you specify a type that is different than what you drag into the field, it also will not update.

Here’s my example:

public override void OnInspectorGUI()
{
    var customCamera = (target as CustomCamera);
    customCamera.CameraBoundingBox = EditorGUILayout.ObjectField("CameraBoundingBox ", customCamera.CameraBoundingBox , typeof(MeshCollider), true) as MeshCollider;
}