From 366dc4c0fd7ba803628a0da70476ec42d23ecd7b Mon Sep 17 00:00:00 2001 From: Simon Rodriguez Date: Mon, 13 May 2019 10:02:43 +0200 Subject: [PATCH] A dictionary cant be changed while being enumerated. Now clones the keys and gets/sets values. --- Scripts/Editor/NodeEditorPreferences.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Scripts/Editor/NodeEditorPreferences.cs b/Scripts/Editor/NodeEditorPreferences.cs index 3af06b9..2f84a4a 100644 --- a/Scripts/Editor/NodeEditorPreferences.cs +++ b/Scripts/Editor/NodeEditorPreferences.cs @@ -158,11 +158,13 @@ namespace XNodeEditor { //Label EditorGUILayout.LabelField("Types", EditorStyles.boldLabel); + //Clone keys so we can enumerate the dictionary and make changes. + var typeColorKeys = new List(typeColors.Keys); + //Display type colors. Save them if they are edited by the user - foreach (var typeColor in typeColors) { - Type type = typeColor.Key; + foreach (var type in typeColorKeys) { string typeColorKey = NodeEditorUtilities.PrettyName(type); - Color col = typeColor.Value; + Color col = typeColors[type]; EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); col = EditorGUILayout.ColorField(typeColorKey, col);