/// <summary> /// Saves the settings. /// </summary> /// <param name="path">Path.</param> public static void SaveSettings(string path, string settingKey, UnityEngine.Object target) { if (settings != null && _settingDictionary != null) { if (_settingDictionary.dict.ContainsKey(settingKey)) { // Remove settings if (target == null) { settings = null; _settingDictionary.dict.Remove(settingKey); } else { _settingDictionary.dict[settingKey] = settings; } } else { // Add the settings to _settingDictionary _settingDictionary.dict.Add(settingKey, settings); } // Save the setting dictionary EditorUtility.SetDirty(_settingDictionary); if (!AssetDatabase.Contains(_settingDictionary)) { AssetDatabase.CreateAsset(_settingDictionary, path); } AssetDatabase.SaveAssets(); } }
public static void PreferencesGUI() { // Load the preferences LoadPreferences(); EditorGUILayout.LabelField("Settings Path"); _defaultSettingsPath = EditorGUILayout.TextField(_defaultSettingsPath); // Save the preferences if (GUI.changed) { EditorPrefs.SetString("IAPManagerProSettingsPath", _defaultSettingsPath); settings = null; } }
/// <summary> /// Creates the settings. /// </summary> /// <param name="path">Path.</param> public static List <string> CreateSettings(string path, string settingKey, bool isShopEditor) { List <string> keys = null; if (settings == null || settings.key != settingKey) { // Get the setting list _settingDictionary = (IAPEditorSettingsDictionary)EditorGUIUtility.Load(path); // Check if the file exist if (_settingDictionary == null) { // Create the new IAPEditorSettingsList _settingDictionary = ScriptableObject.CreateInstance <IAPEditorSettingsDictionary>(); // Create new settings settings = new IAPEditorSettings(); settings.key = settingKey; } else { // if the file exist and contains the key/value if (_settingDictionary.dict.ContainsKey(settingKey)) { settings = _settingDictionary.dict[settingKey]; } else if (isShopEditor) { // Create new settings settings = new IAPEditorSettings(); settings.key = settingKey; } keys = new List <string>(_settingDictionary.dict.Keys); } } return(keys); }