private static void TypeColorsGUI(string key, GameFlowEditorSettings settings) { //Label EditorGUILayout.LabelField("Types", EditorStyles.boldLabel); //Display type colors. Save them if they are edited by the user var typeColorKeys = new List <string>(typeColors.Keys); foreach (var typeColorKey in typeColorKeys) { var col = typeColors[typeColorKey]; EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); col = EditorGUILayout.ColorField(typeColorKey, col); EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { typeColors[typeColorKey] = col; if (settings.typeColors.ContainsKey(typeColorKey)) { settings.typeColors[typeColorKey] = col; } else { settings.typeColors.Add(typeColorKey, col); } SavePrefs(typeColorKey, settings); NodeEditorWindow.RepaintAll(); } } }
private static void SystemSettingsGUI(string key, GameFlowEditorSettings settings) { //Label EditorGUILayout.LabelField("System", EditorStyles.boldLabel); settings.autoSave = EditorGUILayout.Toggle(new GUIContent("Autosave", "Disable for better editor performance"), settings.autoSave); if (GUI.changed) { SavePrefs(key, settings); } EditorGUILayout.Space(); }
private static void NodeSettingsGUI(string key, GameFlowEditorSettings settings) { //Label EditorGUILayout.LabelField("Node", EditorStyles.boldLabel); settings.highlightColor = EditorGUILayout.ColorField("Selection", settings.highlightColor); settings.noodleType = (NodeEditorNoodleType)EditorGUILayout.EnumPopup("Noodle type", settings.noodleType); if (GUI.changed) { SavePrefs(key, settings); NodeEditorWindow.RepaintAll(); } EditorGUILayout.Space(); }
private static void GridSettingsGUI(string key, GameFlowEditorSettings settings) { //Label EditorGUILayout.LabelField("Grid", EditorStyles.boldLabel); settings.gridSnap = EditorGUILayout.Toggle(new GUIContent("Snap", "Hold CTRL in editor to invert"), settings.gridSnap); settings.gridLineColor = EditorGUILayout.ColorField("Color", settings.gridLineColor); settings.gridBgColor = EditorGUILayout.ColorField(" ", settings.gridBgColor); if (GUI.changed) { SavePrefs(key, settings); NodeEditorWindow.RepaintAll(); } EditorGUILayout.Space(); }
/// <summary> Save preferences in EditorPrefs </summary> private static void SavePrefs(string key, GameFlowEditorSettings settings) { EditorPrefs.SetString(key, JsonUtility.ToJson(settings)); }