protected virtual void OnEnable() { Utility.RegisterWindow(this); Utility.RestoreIcon(this, NGSettingsWindow.TitleColor); if (NGSettingsWindow.sections.Count > 0) { this.workingSection = NGSettingsWindow.sections[0]; } this.r = new Rect(0F, 40F, NGSettingsWindow.SectionWidth, 0F); this.body = new Rect(0F, 0F, NGSettingsWindow.SectionWidth, 0F); this.viewRect = new Rect(); HQ.SettingsChanged += this.Repaint; Undo.undoRedoPerformed += this.Repaint; EditorApplication.delayCall += () => { // As crazy as it seems, we need 3 nested delayed calls. Because we need to ensure everybody is in the room to start the party. this.Focus(NGEditorPrefs.GetString(NGSettingsWindow.LastSectionPrefKey)); this.Repaint(); }; this.wantsMouseMove = true; }
public override void DirectSave(object instance, Type type, string path) { Vector2 value = (Vector2)instance; NGEditorPrefs.SetFloat(path + ".x", value.x); NGEditorPrefs.SetFloat(path + ".y", value.y); }
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); } }
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 string GetString(string key, string defaultValue = "", bool perProject = false) { if (perProject == true) { key = NGEditorPrefs.GetPerProjectPrefix() + key; } return(EditorPrefs.GetString(key, defaultValue)); }
public static void DeleteKey(string key, bool perProject = false) { if (perProject == true) { key = NGEditorPrefs.GetPerProjectPrefix() + key; } EditorPrefs.DeleteKey(key); }
private static void ResetAssets() { if (HQ.settings == null) { NGEditorPrefs.DeleteKey(Constants.ConfigPathKeyPref, true); GUICallbackWindow.Open(() => HQ.LoadSharedNGSetting()); } }
public override object Fetch(object instance, Type type, string path) { Int64 result; if (Int64.TryParse(NGEditorPrefs.GetString(path), out result) == true) return result; return instance; }
public static bool HasKey(string key, bool perProject = false) { if (perProject == true) { key = NGEditorPrefs.GetPerProjectPrefix() + key; } return(EditorPrefs.HasKey(key)); }
public static float GetFloat(string key, float defaultValue = 0F, bool perProject = false) { if (perProject == true) { key = NGEditorPrefs.GetPerProjectPrefix() + key; } return(EditorPrefs.GetFloat(key, defaultValue)); }
public static void SetString(string key, string value, bool perProject = false) { if (perProject == true) { key = NGEditorPrefs.GetPerProjectPrefix() + key; } EditorPrefs.SetString(key, value); }
public static int GetInt(string key, int defaultValue = 0, bool perProject = false) { if (perProject == true) { key = NGEditorPrefs.GetPerProjectPrefix() + key; } return(EditorPrefs.GetInt(key, defaultValue)); }
public static bool GetBool(string key, bool defaultValue = false, bool perProject = false) { if (perProject == true) { key = NGEditorPrefs.GetPerProjectPrefix() + key; } return(EditorPrefs.GetBool(key, defaultValue)); }
public override void DirectSave(object instance, Type type, string path) { Color value = (Color)instance; NGEditorPrefs.SetFloat(path + ".r", value.r); NGEditorPrefs.SetFloat(path + ".g", value.g); NGEditorPrefs.SetFloat(path + ".b", value.b); NGEditorPrefs.SetFloat(path + ".a", value.a); }
public override void DirectSave(object instance, Type type, string path) { Rect value = (Rect)instance; NGEditorPrefs.SetFloat(path + ".x", value.x); NGEditorPrefs.SetFloat(path + ".y", value.y); NGEditorPrefs.SetFloat(path + ".w", value.width); NGEditorPrefs.SetFloat(path + ".h", value.height); }
public override void DirectSave(object instance, Type type, string path) { Quaternion value = (Quaternion)instance; NGEditorPrefs.SetFloat(path + ".x", value.x); NGEditorPrefs.SetFloat(path + ".y", value.y); NGEditorPrefs.SetFloat(path + ".z", value.z); NGEditorPrefs.SetFloat(path + ".w", value.w); }
public override object Fetch(object instance, Type type, string path) { Vector2 value = (Vector2)instance; value.x = NGEditorPrefs.GetFloat(path + ".x", value.x); value.y = NGEditorPrefs.GetFloat(path + ".y", value.y); return(value); }
public override object Fetch(object instance, Type type, string path) { Decimal result; if (Decimal.TryParse(NGEditorPrefs.GetString(path), out result) == true) { return(result); } return(instance); }
public override object Fetch(object instance, Type type, string path) { Rect value = (Rect)instance; value.x = NGEditorPrefs.GetFloat(path + ".x", value.x); value.y = NGEditorPrefs.GetFloat(path + ".y", value.y); value.width = NGEditorPrefs.GetFloat(path + ".w", value.width); value.height = NGEditorPrefs.GetFloat(path + ".h", value.height); return(value); }
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 object Fetch(object instance, Type type, string path) { Quaternion value = (Quaternion)instance; value.x = NGEditorPrefs.GetFloat(path + ".x", value.x); value.y = NGEditorPrefs.GetFloat(path + ".y", value.y); value.z = NGEditorPrefs.GetFloat(path + ".z", value.z); value.w = NGEditorPrefs.GetFloat(path + ".w", value.w); return(value); }
public override object Fetch(object instance, Type type, string path) { Color value = (Color)instance; value.r = NGEditorPrefs.GetFloat(path + ".r", value.r); value.g = NGEditorPrefs.GetFloat(path + ".g", value.g); value.b = NGEditorPrefs.GetFloat(path + ".b", value.b); value.a = NGEditorPrefs.GetFloat(path + ".a", value.a); return(value); }
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 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); }
private static void OpenWindow(string type, string value) { UnityAssemblyVerifier.missing.Add(new KeyValuePair <string, string>(type, value)); UnityAssemblyVerifier.cachedMissing = null; EditorApplication.delayCall += () => { if (NGEditorPrefs.GetBool(UnityAssemblyVerifier.SkipWarningPrefKey) == false) { EditorWindow.GetWindow <UnityAssemblyVerifier>(true, Constants.PackageTitle).CenterOnMainWin(); } }; }
public static void CheckLatestVersion(string toolName) { if (NGEditorPrefs.GetBool(NGChangeLogWindow.DontNotifyNewUpdateKeyPref) == true) { return; } try { // Prevent repeating initialization. foreach (KeyValuePair <string, int> item in NGChangeLogWindow.pendingTools) { if (item.Key == toolName) { return; } } List <ChangeLog> changeLog; if (NGChangeLogWindow.changeLogs.TryGetValue(toolName, out changeLog) == true) { changeLog.Sort((a, b) => a.version.CompareTo(b.version)); string local = NGChangeLogWindow.GetToolPath(toolName); if (File.Exists(local) == true) { string version = File.ReadAllText(local); for (int i = 0; i < changeLog.Count; i++) { if (version.CompareTo(changeLog[i].version) < 0) { NGChangeLogWindow.pendingTools.Enqueue(new KeyValuePair <string, int>(toolName, i)); NGChangeLogWindow.Open(); break; } } } else { File.WriteAllText(local, changeLog[changeLog.Count - 1].version); } } } catch (Exception ex) { InternalNGDebug.LogException(ex); } }
public void EraseAll(bool silent = false) { this.disabledTips.Clear(); if (NGEditorPrefs.HasKey(key) == true) { NGEditorPrefs.DeleteKey(key); } if (silent == false) { EditorUtility.DisplayDialog(Constants.PackageTitle, "Tips have been reset.", "OK"); } }
internal static void SetSendStats(object sendStats) { if ((bool)sendStats == false) { if (EditorUtility.DisplayDialog(Constants.PackageTitle, "For those who might want to know why I send stats.\nI need some info about Unity Editor usage, especially because Unity does not provide them.\nIn order to keep supporting legacy versions, unused tools or platforms such as Unity 4, Mac or else.\n\nDo you confirm not sending stats?", "Yes", "No") == false) { return; } HQ.SendStats(false); } NGEditorPrefs.SetBool(HQ.AllowSendStatsKeyPref, (bool)sendStats); }
public void Load(string key) { this.key = key; string data = NGEditorPrefs.GetString(key); if (string.IsNullOrEmpty(data) == false) { this.disabledTips.AddRange(data.Split(TipsHelper.Separator)); } else { this.EraseAll(true); } }