protected virtual void DrawSettings(bool isBase) { List <QuickSetting> settings = isBase ? QuickPlayerPrefs.GetSettingsBase() : QuickPlayerPrefs.GetSettingsCustom(); if (settings.Count == 0) { return; } EditorGUI.indentLevel++; //Draw the "Name Value" column GUILayout.BeginVertical(); EditorGUILayout.LabelField("Name", "Value"); foreach (QuickSetting s in settings) { GUILayout.BeginHorizontal(); string key = s.GetKey(); string typeName = s.GetTypeName(); QuickPlayerPrefs.SetValue(key, DrawPlayerPref(key, typeName)); if (!isBase) { if (QuickBaseEditor.DrawButton("-", GUILayout.Width(32))) { QuickPlayerPrefs.DeleteSetting(key); break; } } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); EditorGUI.indentLevel--; }
protected virtual void DrawNewSettingsArea(GUILayoutOption[] options) { _showNewSetting = EditorGUILayout.Foldout(_showNewSetting, "New Setting"); if (_showNewSetting) { EditorGUI.indentLevel++; _newSettingKey = EditorGUILayout.TextField("Key: ", _newSettingKey, options); _newSettingType = (PrefType)EditorGUILayout.EnumPopup("Type: ", _newSettingType, options); if (_newSettingType == PrefType.Enum) { _newSettingTypeEnum = EditorGUILayout.TextField("Enum Type: ", _newSettingTypeEnum, options); } EditorGUI.indentLevel--; if (QuickBaseEditor.DrawButton("Create New Setting", options)) { object value = null; if (_newSettingKey.Length == 0) { EditorUtility.DisplayDialog("New Setting Creation Error", "The Key string cannot be empty", "Ok"); } else if (QuickPlayerPrefs.HasKey(_newSettingKey)) { EditorUtility.DisplayDialog("New Setting Creation Error", "The Key " + _newSettingKey + " already exists", "Ok"); } else if (CreateNewSetting(out value)) { QuickPlayerPrefs.SetValue(_newSettingKey, value); _newSettingKey = _newSettingTypeEnum = ""; _newSettingType = PrefType.String; } } } }