diff --git a/Scripts/Editor/NodeEditorPreferences.cs b/Scripts/Editor/NodeEditorPreferences.cs index 4fc6b7b..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); @@ -171,7 +173,7 @@ namespace XNodeEditor { typeColors[type] = col; if (settings.typeColors.ContainsKey(typeColorKey)) settings.typeColors[typeColorKey] = col; else settings.typeColors.Add(typeColorKey, col); - SavePrefs(typeColorKey, settings); + SavePrefs(key, settings); NodeEditorWindow.RepaintAll(); } }