InvalidOperationException: Collection was modified

having an error pop up and when i add a new node it creates 2?

    private void OnGUI()
    {
        if (selectedDialogue == null)
        {
            EditorGUILayout.LabelField("Hello World");
        }
        else
        {
            ProcessEvents();
            foreach (DialogueNode node in selectedDialogue.GetAllNodes())
            {
                DrawNode(node);
            }
            foreach (DialogueNode node in selectedDialogue.GetAllNodes())
            {
                DrawConnections(node);
            }
            if (createingNode != null)
            {
                Undo.RecordObject(selectedDialogue, "Added Dialogue Node");
                selectedDialogue.CreateNode(createingNode);
                createingNode = null;
            }
        }
    }

i figured it out :slight_smile:

I’m curious as to the issue. The fragment I see shouldn’t yield a Collection error, as you’re creating outside of a GetAllNodes foreach loop.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms