internal static void SetStatsComplementary(string key, string value) { string complementary = NGEditorPrefs.GetString(HQ.ComplementaryKeyPref); List <string> data = new List <string>(); bool found = false; if (string.IsNullOrEmpty(complementary) == false) { data.AddRange(complementary.Split(HQ.ComplementarySeparator)); } for (int i = 0; i < data.Count; i++) { if (data[i].StartsWith(key + '=') == true) { found = true; if (string.IsNullOrEmpty(value) == true) { data.RemoveAt(i--); } else { data[i] = key + '=' + value; } } } if (found == false) { data.Add(key + '=' + value); } NGEditorPrefs.SetString(HQ.ComplementaryKeyPref, string.Join(HQ.ComplementarySeparator.ToString(), data.ToArray())); }
public static void CreateNGSettings(string path) { try { NGSettings asset = ScriptableObject.CreateInstance <NGSettings>(); AssetDatabase.CreateAsset(asset, path); AssetDatabase.SaveAssets(); NGEditorPrefs.SetString(Constants.ConfigPathKeyPref, path, true); HQ.SetSettings(asset); // Need to skip many frames before really writing the data. Don't know why it requires 2 frames. EditorApplication.delayCall += () => { EditorApplication.delayCall += () => { HQ.InvalidateSettings(); AssetDatabase.SaveAssets(); }; }; } catch (Exception ex) { InternalNGDebug.LogException(ex); HQ.SetSettings(null); } }
public void Focus(string title) { for (int i = 0; i < NGSettingsWindow.sections.Count; i++) { if (NGSettingsWindow.sections[i].title == title) { this.workingSection = NGSettingsWindow.sections[i]; NGEditorPrefs.SetString(NGSettingsWindow.LastSectionPrefKey, this.workingSection.title); } } }
protected virtual void OnDisable() { Utility.UnregisterWindow(this); HQ.SettingsChanged -= this.Repaint; Undo.undoRedoPerformed -= this.Repaint; if (this.workingSection != null) { NGEditorPrefs.SetString(NGSettingsWindow.LastSectionPrefKey, this.workingSection.title); } }
public void Save() { if (this.disabledTips.Count > 0) { NGEditorPrefs.SetString(key, string.Join(TipsHelper.Separator.ToString(), this.disabledTips.ToArray())); } else if (NGEditorPrefs.HasKey(key) == true) { NGEditorPrefs.DeleteKey(key); } }
public override void DirectSave(object instance, Type type, string path) { Object obj = instance as Object; string assetPath = string.Empty; if (obj != null) { assetPath = AssetDatabase.GetAssetPath(obj); } NGEditorPrefs.SetString(path, assetPath); }
public override void DirectSave(object instance, Type type, string path) { Array array = instance as Array; if (array == null) { NGEditorPrefs.DeleteKey(path); return; } NGEditorPrefs.SetInt(path, array.Length); try { if (array.Length > 0) { Type subType = Utility.GetArraySubType(type); if (subType.IsValueType == true || subType == typeof(string) || subType.IsInterface == true || subType.IsAbstract == true) { NGEditorPrefs.SetString(path + ".serialized", Convert.ToBase64String(Utility.SerializeField(array))); return; } } for (int i = 0; i < array.Length; i++) { object value = array.GetValue(i); if (value != null) { Utility.DirectSaveEditorPref(value, value.GetType(), path + '.' + i); } else { NGEditorPrefs.DeleteKey(path + '.' + i); } } } catch (Exception ex) { InternalNGDebug.LogException("EditorPrefArray failed saving at \"" + path + "\".", ex); } }
public override void DirectSave(object instance, Type type, string path) { IList list = instance as IList; if (list == null) { NGEditorPrefs.DeleteKey(path); return; } NGEditorPrefs.SetInt(path, list.Count); try { if (list.Count > 0) { Type subType = Utility.GetArraySubType(type); if ((subType.IsValueType == true && subType.IsStruct() == false) || subType == typeof(string) || subType.IsInterface == true || subType.IsAbstract == true) { NGEditorPrefs.SetString(path + ".serialized", Convert.ToBase64String(Utility.SerializeField(list))); return; } } for (int i = 0; i < list.Count; i++) { object value = list[i]; if (value != null) { Utility.DirectSaveEditorPref(value, value.GetType(), path + '.' + i); } else { NGEditorPrefs.DeleteKey(path + '.' + i); } } } catch (Exception ex) { InternalNGDebug.LogException("EditorPrefList failed saving at \"" + path + "\".", ex); } }
public override void DirectSave(object instance, Type type, string path) { NGEditorPrefs.SetString(path, ((Decimal)instance).ToString()); }
public static void SaveLanguage(string language) { NGEditorPrefs.SetString(Constants.LanguageEditorPref, language); }
public override void DirectSave(object instance, Type type, string path) { NGEditorPrefs.SetString(path, (String)instance); }