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; }
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 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 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 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); } }
internal static string GetStatsComplementary(string key) { string complementary = NGEditorPrefs.GetString(HQ.ComplementaryKeyPref); string[] data = complementary.Split(HQ.ComplementarySeparator); for (int i = 0; i < data.Length; i++) { if (data[i].StartsWith(key + '=') == true) { return(data[i].Substring(key.Length + 1)); } } return(string.Empty); }
public override object Fetch(object instance, Type type, string path) { if (NGEditorPrefs.HasKey(path) == true) { string assetPath = NGEditorPrefs.GetString(path, string.Empty); if (assetPath != string.Empty) { if (assetPath == "Library/unity editor resources") { return(instance); } return(AssetDatabase.LoadAssetAtPath(assetPath, type) ?? instance); } return(null); } return(instance); }
public override object Fetch(object instance, Type type, string path) { int length = NGEditorPrefs.GetInt(path, -1); if (length == -1) { return(instance); } Type subType = type.GetElementType(); if (length > 0 && (subType.IsValueType == true || subType == typeof(string) || subType.IsInterface == true || subType.IsAbstract == true)) { string v = NGEditorPrefs.GetString(path + ".serialized", null); if (v != null) { return(Utility.DeserializeField(Convert.FromBase64String(v))); } return(instance); } Array array = Array.CreateInstance(subType, length); try { for (int i = 0; i < array.Length; i++) { object element = null; try { if (subType.IsValueType == true) { element = Activator.CreateInstance(subType); } else if (subType != typeof(string)) { try { element = Activator.CreateInstance(subType); } catch (MissingMethodException) { element = FormatterServices.GetUninitializedObject(subType); } } } catch (Exception ex) { InternalNGDebug.LogException(ex); break; } element = Utility.LoadEditorPref(element, subType, path + '.' + i); array.SetValue(element, i); } return(array); } catch (Exception ex) { InternalNGDebug.LogException("EditorPrefArray failed fetching at \"" + path + "\".", ex); } return(instance); }
public override object Fetch(object instance, Type type, string path) { int count = NGEditorPrefs.GetInt(path, -1); if (count == -1) { return(instance); } Type subType = Utility.GetArraySubType(type); if (count > 0 && ((subType.IsValueType == true && subType.IsStruct() == false) || subType == typeof(string) || subType.IsInterface == true || subType.IsAbstract == true)) { string v = NGEditorPrefs.GetString(path + ".serialized", null); if (string.IsNullOrEmpty(v) == false) { return(Utility.DeserializeField(Convert.FromBase64String(v))); } return(instance); } IList list = Activator.CreateInstance(type) as IList; try { for (int i = 0; i < count; i++) { object element = null; try { if (subType.IsValueType == true) { element = Activator.CreateInstance(subType); } else if (subType != typeof(string)) { try { element = Activator.CreateInstance(subType); } catch (MissingMethodException) { element = FormatterServices.GetUninitializedObject(subType); } } } catch (Exception ex) { InternalNGDebug.LogException(ex); break; } element = Utility.LoadEditorPref(element, subType, path + '.' + i); list.Add(element); } return(list); } catch (Exception ex) { InternalNGDebug.LogException("EditorPrefList failed fetching at \"" + path + "\".", ex); } return(instance); }
/// <summary> /// For the curious who might want to know why I send these stats. /// I need some info about Unity Editor usage, especially because Unity does not provide them. /// In order to keep supporting old versions or platforms. /// </summary> /// <param name="sendStats"></param> internal static void SendStats(bool sendStats = true) { string path = Path.Combine(Application.persistentDataPath, Path.Combine(Constants.InternalPackageTitle, "sendStats." + Utility.UnityVersion + "." + Constants.Version + ".txt")); bool sentOnce = false; string today = DateTime.Now.ToString("yyyyMMdd"); if (File.Exists(path) == true) { string lastTime = File.ReadAllText(path); if (lastTime == today) { sentOnce = true; } } if (sentOnce == false) { try { Directory.CreateDirectory(Path.GetDirectoryName(path)); File.WriteAllText(path, today); } catch { string rawSentOnceCount = HQ.GetStatsComplementary("SSSOC"); int errorCount; if (string.IsNullOrEmpty(rawSentOnceCount) == false && int.TryParse(rawSentOnceCount, out errorCount) == true) { HQ.SetStatsComplementary("SSSOC", (errorCount + 1).ToString()); } else { HQ.SetStatsComplementary("SSSOC", "1"); } } } if (sentOnce == false || sendStats == false) { StringBuilder buffer = Utility.GetBuffer(HQ.ServerEndPoint + "unityeditor.php?u="); buffer.Append(Utility.UnityVersion); buffer.Append("&o="); buffer.Append(SystemInfo.operatingSystem); buffer.Append("&p="); buffer.Append(Constants.Version); buffer.Append("&n="); buffer.Append(SystemInfo.deviceName); buffer.Append("&un="); buffer.Append(Environment.UserName); buffer.Append("&ut="); buffer.Append(Metrics.GetUsedTools()); Metrics.ResetUsedTools(); buffer.Append("&m="); buffer.Append(HQ.GetMACAddressHash()); foreach (License license in NGLicensesManager.EachInvoices()) { if (license.active == true && license.status != Status.Banned) { buffer.Append("&in[]="); buffer.Append(license.invoice); } } foreach (HQ.ToolAssemblyInfo tool in HQ.EachTool) { buffer.Append("&to[]="); buffer.Append(tool.name); buffer.Append(":"); buffer.Append(tool.version); } string complementary = NGEditorPrefs.GetString(HQ.ComplementaryKeyPref); if (string.IsNullOrEmpty(complementary) == false) { buffer.Append("&com=" + complementary); } if (sendStats == false) { buffer.Append("&s"); } Utility.RequestURL(Utility.ReturnBuffer(buffer), (s, r) => { if (s == Utility.RequestStatus.Completed) { NGEditorPrefs.DeleteKey(HQ.ComplementaryKeyPref); } else { string rawErrorCount = HQ.GetStatsComplementary("SSEC"); int errorCount; if (string.IsNullOrEmpty(rawErrorCount) == false && int.TryParse(rawErrorCount, out errorCount) == true) { HQ.SetStatsComplementary("SSEC", (errorCount + 1).ToString()); } else { HQ.SetStatsComplementary("SSEC", "1"); } } }); } }
public static string CurrentLanguage() { return(NGEditorPrefs.GetString(Constants.LanguageEditorPref)); }
public override object Fetch(object instance, Type type, string path) { return(NGEditorPrefs.GetString(path, (String)instance)); }