mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 17:56:06 +08:00
Fixed #99 - Color for types in preferences will reseted after playing
* SavePrefs was saving to the wrong key. * A dictionary cant be changed while being enumerated. Now clones the keys and gets/sets values.
This commit is contained in:
parent
d68aea2a8a
commit
c868c037ea
@ -158,11 +158,13 @@ namespace XNodeEditor {
|
|||||||
//Label
|
//Label
|
||||||
EditorGUILayout.LabelField("Types", EditorStyles.boldLabel);
|
EditorGUILayout.LabelField("Types", EditorStyles.boldLabel);
|
||||||
|
|
||||||
|
//Clone keys so we can enumerate the dictionary and make changes.
|
||||||
|
var typeColorKeys = new List<Type>(typeColors.Keys);
|
||||||
|
|
||||||
//Display type colors. Save them if they are edited by the user
|
//Display type colors. Save them if they are edited by the user
|
||||||
foreach (var typeColor in typeColors) {
|
foreach (var type in typeColorKeys) {
|
||||||
Type type = typeColor.Key;
|
|
||||||
string typeColorKey = NodeEditorUtilities.PrettyName(type);
|
string typeColorKey = NodeEditorUtilities.PrettyName(type);
|
||||||
Color col = typeColor.Value;
|
Color col = typeColors[type];
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
EditorGUILayout.BeginHorizontal();
|
EditorGUILayout.BeginHorizontal();
|
||||||
col = EditorGUILayout.ColorField(typeColorKey, col);
|
col = EditorGUILayout.ColorField(typeColorKey, col);
|
||||||
@ -171,7 +173,7 @@ namespace XNodeEditor {
|
|||||||
typeColors[type] = col;
|
typeColors[type] = col;
|
||||||
if (settings.typeColors.ContainsKey(typeColorKey)) settings.typeColors[typeColorKey] = col;
|
if (settings.typeColors.ContainsKey(typeColorKey)) settings.typeColors[typeColorKey] = col;
|
||||||
else settings.typeColors.Add(typeColorKey, col);
|
else settings.typeColors.Add(typeColorKey, col);
|
||||||
SavePrefs(typeColorKey, settings);
|
SavePrefs(key, settings);
|
||||||
NodeEditorWindow.RepaintAll();
|
NodeEditorWindow.RepaintAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user