public void DrawLoadSaveGUI(TerrainInfo info, Dictionary <string, bool> EditorWidgetFoldouts) { // Draws the GUI widgets for picking and deleting parameters FoldoutParameterPresets = EditorGUILayout.Foldout(FoldoutParameterPresets, "Parameter Presets"); if (FoldoutParameterPresets) { if (AllParameterNames.Length > 0) { GUILayout.Label("Saved parameter presets"); GUILayout.BeginHorizontal(GUILayout.Width(250)); var lastIndex = CurrentSelectedIndex; CurrentSelectedIndex = EditorGUILayout.Popup(CurrentSelectedIndex, AllParameterNames, GUILayout.Width(250)); DeleteFailsafe = lastIndex != CurrentSelectedIndex ? 0 : DeleteFailsafe; if (GUILayout.Button(string.Format("Delete selected preset ({0})", DeleteFailsafe), GUILayout.MaxWidth(200))) { if (DeleteFailsafe == 2) { DeleteFailsafe = 0; SerializationManager.DeleteTerrainParameter(AllParameterNames[CurrentSelectedIndex]); AllParameters.RemoveAt(CurrentSelectedIndex); TryGeneratingSavedParameterList(); } else { DeleteFailsafe++; } } GUILayout.EndHorizontal(); if (GUI.Button(EditorGUILayout.GetControlRect(), "Load preset")) { TryGeneratingSavedParameterList(); for (int i = 0; i < SerializedTerrainParameters.Count; i++) { var parameter = SerializedTerrainParameters[i]; parameter.TerrainColor = new Color(parameter.TerrainColorVector.x, parameter.TerrainColorVector.y, parameter.TerrainColorVector.z, 1); EditorUtils.ValidateTexture(ref parameter); SerializedTerrainParameters[i] = parameter; // if info not null, means we in runtime, so we need to update the info with new loaded params if (info != null) { info.TerrainParameterList = SerializedTerrainParameters; } } ReorderableParameterList = null; } EditorGUI.LabelField(EditorGUILayout.GetControlRect(), "Terrain parameter serializer, saves the current terrain preset configuration."); TerrainPresetName = EditorGUI.TextField(EditorGUILayout.GetControlRect(), "Terrain preset name: ", TerrainPresetName); if (GUI.Button(EditorGUILayout.GetControlRect(), "Save preset")) { SerializationManager.SaveTerrainPreset(TerrainPresetName, SerializedTerrainParameters); TryGeneratingSavedParameterList(); } EditorPrefs.SetInt("ParameterPresetIdx", CurrentSelectedIndex); if (info != null) { info.TerrainParameterList = SerializedTerrainParameters; } } } }