public void OnGUILayout() { // Use this trick to avoid layout error when the exception is raised. if (Event.current.type == EventType.Layout) { this.workingException = this.exception; } if (this.workingException == null) { return; } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.HelpBox(this.customMessage, MessageType.Error); Rect r = GUILayoutUtility.GetLastRect(); this.HandleEvents(GUILayoutUtility.GetLastRect()); r.x = r.x + r.width + 1F; r.width = GUILayoutUtility.GetRect(25F, r.height, GUI.skin.button, GUILayoutOptionPool.Width(25F)).width + 4F; if (GUI.Button(r, "X") == true) { this.ClearException(); } } EditorGUILayout.EndHorizontal(); }
protected virtual void OnGUI() { if (ViewTextWindow.style == null) { ViewTextWindow.style = new GUIStyle(EditorStyles.label); ViewTextWindow.style.wordWrap = true; } if (this.init == false) { this.init = true; Utility.content.text = text; Vector2 size = EditorStyles.textArea.CalcSize(Utility.content); float y = this.position.y; this.position = new Rect(this.position.x, this.position.y, size.x + 8F, size.y + 4F); // In case the window gets too large, reduce it and adapt height. if (this.position.width < size.x + 8F) { // Due to wrap behaviour, we need to shrink it step by step. float width = this.position.width; float height = ViewTextWindow.style.CalcHeight(Utility.content, width) + 8F; do { width -= 10F; }while (width > 100F && Mathf.Approximately(height, ViewTextWindow.style.CalcHeight(Utility.content, width) + 8F) == true); width += 20F; this.position = new Rect(this.position.x, y, width, height); this.Repaint(); } GUI.FocusControl(null); } this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, GUILayoutOptionPool.Width(this.position.width), GUILayoutOptionPool.Height(this.position.height)); EditorGUILayout.TextArea(this.text, ViewTextWindow.style, GUILayoutOptionPool.ExpandWidthTrue, GUILayoutOptionPool.ExpandHeightTrue); GUILayout.EndScrollView(); }
protected virtual void OnGUI() { if (string.IsNullOrEmpty(this.requestError) == false) { EditorGUILayout.HelpBox(this.requestError, MessageType.Error); } GUILayout.Label(LC.G("ContactFormWizard_Title"), GeneralStyles.MainTitle); this.contactName = EditorGUILayout.TextField(LC.G("ContactFormWizard_ContactName"), this.contactName); if (string.IsNullOrEmpty(this.contactName) == true) { EditorGUILayout.HelpBox(LC.G("ContactFormWizard_NameRequired"), MessageType.Warning); } this.contactEMail = EditorGUILayout.TextField(LC.G("ContactFormWizard_ContactEMail"), this.contactEMail); if (Regex.IsMatch(this.contactEMail, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase) == false) { EditorGUILayout.HelpBox(LC.G("ContactFormWizard_ValidEMailRequired"), MessageType.Warning); } this.subject = (Subject)EditorGUILayout.EnumPopup("Subject", this.subject); this.specificTools = EditorGUILayout.TextField("Specific Tools", this.specificTools); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Add information about", GUILayoutOptionPool.Width(145F)); this.packageInformation = GUILayout.Toggle(this.packageInformation, "Package", "ButtonLeft"); Rect r2 = GUILayoutUtility.GetLastRect(); r2.x += 2F; r2.y += 1F; GUI.Toggle(r2, this.packageInformation, string.Empty); this.unityInformation = GUILayout.Toggle(this.unityInformation, LC.G("ContactFormWizard_UnityInformation"), "ButtonMid"); r2 = GUILayoutUtility.GetLastRect(); r2.x += 2F; r2.y += 1F; GUI.Toggle(r2, this.unityInformation, string.Empty); this.osInformation = GUILayout.Toggle(this.osInformation, LC.G("ContactFormWizard_OSInformation"), "ButtonMid"); r2 = GUILayoutUtility.GetLastRect(); r2.x += 2F; r2.y += 1F; GUI.Toggle(r2, this.osInformation, string.Empty); this.hardwareInformation = GUILayout.Toggle(this.hardwareInformation, LC.G("ContactFormWizard_HardwareInformation"), "ButtonRight"); r2 = GUILayoutUtility.GetLastRect(); r2.x += 2F; r2.y += 1F; GUI.Toggle(r2, this.hardwareInformation, string.Empty); } EditorGUILayout.EndHorizontal(); Rect r = this.position; r.x = 0F; r.y = 20F; r.height -= 20F; Utility.content.text = this.complementaryInformation; EditorGUILayout.LabelField(LC.G("ContactFormWizard_ComplementaryInformation")); this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition); { this.complementaryInformation = EditorGUILayout.TextArea(this.complementaryInformation, GUI.skin.textArea, GUILayoutOptionPool.ExpandWidthTrue, GUILayoutOptionPool.ExpandHeightTrue); } GUILayout.EndScrollView(); if (this.subject == Subject.BugReport) { if (this.packageInformation == false || this.unityInformation == false || this.osInformation == false || this.hardwareInformation == false) { EditorGUILayout.HelpBox(LC.G("ContactFormWizard_BugReportRecommendation"), MessageType.Info); } } EditorGUILayout.HelpBox(LC.G("ContactFormWizard_SupportLanguagesWarning"), MessageType.Info); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("Preview", GUILayoutOptionPool.Width(this.position.width * .45F)) == true) { string tempFilePath = Path.Combine(Application.temporaryCachePath, Path.GetRandomFileName() + ".txt"); File.WriteAllText(tempFilePath, this.PrepareTheEmail()); EditorUtility.OpenWithDefaultApp(tempFilePath); } GUILayout.FlexibleSpace(); using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (this.requesting == true) { GUILayout.Button("Requesting...", GUILayoutOptionPool.Width(this.position.width * .5F)); GUI.Label(GUILayoutUtility.GetLastRect(), GeneralStyles.StatusWheel); this.Repaint(); } else { EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(this.contactName) || string.IsNullOrEmpty(this.contactEMail)); { if (GUILayout.Button("Send", GUILayoutOptionPool.Width(this.position.width * .45F)) == true) { this.SendEmail(); } } EditorGUI.EndDisabledGroup(); } } } EditorGUILayout.EndHorizontal(); }
protected virtual void OnGUI() { if (this.once == false) { this.once = true; float maxHeight = Mathf.Min(40F + 20F + this.seats.Length * (35F + 10F), 150F); this.minSize = new Vector2(this.minSize.x, maxHeight); } EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Invoice: ", GeneralStyles.VerticalCenterLabel, GUILayoutOptionPool.ExpandWidthFalse, GUILayoutOptionPool.Height(40F)); GUILayout.Label(invoice, GeneralStyles.MainTitle); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { GUILayout.Label("Active Seat", GeneralStyles.AllCenterTitle); } EditorGUILayout.EndHorizontal(); this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition); { if (this.seats.Length == 0) { GUILayout.Label("No active seat.", GeneralStyles.InnerBoxText); } else { for (int i = 0; i < this.seats.Length; i += 2) { bool isRevoked = this.seatsRevoked.Contains(this.seats[i]); EditorGUI.BeginDisabledGroup(isRevoked); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(this.seats[i], GeneralStyles.AllCenterTitle, GUILayoutOptionPool.Width(160F), GUILayoutOptionPool.Height(35F)); GUILayout.Label(this.seats[i + 1], GeneralStyles.AllCenterTitle, GUILayoutOptionPool.Width(140F), GUILayoutOptionPool.Height(35F)); GUILayout.FlexibleSpace(); if (isRevoked == true) { GUILayout.Label("[Revoked]", GeneralStyles.AllCenterTitle, GUILayoutOptionPool.ExpandWidthFalse, GUILayoutOptionPool.Height(35F), GUILayoutOptionPool.Width(85F)); } else if (this.seats[i] != "PUBLIC" && this.seats[i + 1] != "LICENSE" && GUILayout.Button("Revoke", GUILayoutOptionPool.ExpandWidthFalse, GUILayoutOptionPool.Height(35F), GUILayoutOptionPool.Width(60F)) == true && ((Event.current.modifiers & Constants.ByPassPromptModifier) != 0 || EditorUtility.DisplayDialog(Constants.PackageTitle, "Confirm revoking \"" + this.seats[i] + " " + this.seats[i + 1] + "\"?", "Yes", "No") == true)) { NGLicensesManager.RevokeSeat(this.invoice, this.seats[i], this.seats[i + 1], this.OnRemoveSeat); } } EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); GUILayout.Space(10F); } } } EditorGUILayout.EndScrollView(); }
protected virtual void OnGUI() { if (this.GUIDs[this.GUIDs.Count - 1] != string.Empty) { this.GUIDs.Add(string.Empty); this.entries.Add(new Entry()); } this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition); { using (LabelWidthRestorer.Get(50F)) { for (int i = 0; i < this.GUIDs.Count; i++) { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical(); { EditorGUI.BeginChangeCheck(); this.GUIDs[i] = EditorGUILayout.TextField("GUID", this.GUIDs[i]); if (EditorGUI.EndChangeCheck() == true) { if (string.IsNullOrEmpty(this.GUIDs[i]) == false) { if (this.entries[i].lastGUID != this.GUIDs[i]) { this.entries[i].lastGUID = this.GUIDs[i]; this.ProcessGUID(i); } } else { this.entries[i].lastGUID = string.Empty; this.entries[i].assetPath = string.Empty; this.entries[i].assetObject = null; this.entries[i].assetPreview = null; } } if (string.IsNullOrEmpty(this.GUIDs[i]) == true) { for (int j = i + 1; j < this.GUIDs.Count;) { if (string.IsNullOrEmpty(this.GUIDs[j]) == true) { this.GUIDs.RemoveAt(j); this.entries.RemoveAt(j); this.Repaint(); } else { break; } } } EditorGUI.BeginChangeCheck(); Object asset = EditorGUILayout.ObjectField("Asset", this.entries[i].assetObject, typeof(Object), false); if (EditorGUI.EndChangeCheck() == true) { this.entries[i].assetObject = asset; if (asset != null) { this.GUIDs[i] = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(asset)); } else { this.GUIDs[i] = string.Empty; } } if (this.entries[i].assetObject != null) { int fileIdentifier = Unsupported.GetLocalIdentifierInFile(this.entries[i].assetObject.GetInstanceID()); EditorGUILayout.TextField("FileId", fileIdentifier.ToString()); } } EditorGUILayout.EndVertical(); if (this.entries[i].assetPreview != null) { EditorGUI.DrawTextureTransparent(GUILayoutUtility.GetRect(0F, 0F, GUILayoutOptionPool.Width(32F), GUILayoutOptionPool.Height(32F)), this.entries[i].assetPreview, ScaleMode.ScaleToFit); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(10F); } } } EditorGUILayout.EndScrollView(); }
private static void OnGUISettings() { if (HQ.Settings == null) { return; } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical(GUILayoutOptionPool.ExpandWidthTrue); GUILayout.Label("Bind a MenuItem with a custom hotkey.", GeneralStyles.SmallLabel); if (GUILayout.Button("Help", GUILayoutOptionPool.Width(50F)) == true) { Application.OpenURL("https://docs.unity3d.com/ScriptReference/MenuItem.html"); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(GUILayoutOptionPool.Width(130F)); if (EditorApplication.isCompiling == true) { using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton)) { GUILayout.Button("Compiling...", GeneralStyles.BigButton); } } else { EditorGUI.BeginDisabledGroup(NGHotkeys.DetectDiff(true) == false); if (GUILayout.Button("Save", GeneralStyles.BigButton) == true) { NGHotkeys.Generate(); HQ.InvalidateSettings(HQ.Settings, true); } EditorGUI.EndDisabledGroup(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); Rect r2 = GUILayoutUtility.GetLastRect(); r2.x = 2F; r2.width += 13F; r2.yMin = r2.yMax - 1F; EditorGUI.DrawRect(r2, Color.gray); CustomHotkeysSettings settings = HQ.Settings.Get <CustomHotkeysSettings>(); NGHotkeys.scrollPosition = EditorGUILayout.BeginScrollView(NGHotkeys.scrollPosition); { for (int i = 0; i < NGHotkeys.shortcuts.Count; i++) { EditorGUILayout.BeginHorizontal(); { MenuItemShortcut shortcut = NGHotkeys.shortcuts[i]; CustomHotkeysSettings.MethodHotkey hotkey = null; for (int j = 0; j < settings.hotkeys.Count; j++) { if (settings.hotkeys[j].staticMethod == [email protected] + '.' + shortcut.staticMethod) { hotkey = settings.hotkeys[j]; break; } } Utility.content.text = shortcut.name; Rect r = GUILayoutUtility.GetRect(Utility.content, GUI.skin.label, GUILayoutOptionPool.Width(170F)); EditorGUI.PrefixLabel(r, Utility.content); if (hotkey != null && string.IsNullOrEmpty(hotkey.bind) == false) { float w = r.width; r.x -= 1F; r.width = 1F; EditorGUI.DrawRect(r, Color.cyan); r.x += 1F; r.width = w; } bool hasChanged = false; EditorGUI.BeginChangeCheck(); r.x += r.width; r.width = 50F; string bind = EditorGUI.TextField(r, hotkey != null ? hotkey.bind : string.Empty); if (EditorGUI.EndChangeCheck() == true) { hasChanged = true; } r.x += r.width; r.width = 50F; EditorGUI.BeginChangeCheck(); GUI.Toggle(r, bind.Contains("%"), "Ctrl", GeneralStyles.ToolbarToggle); if (EditorGUI.EndChangeCheck() == true) { GUI.FocusControl(null); hasChanged = true; int n = bind.IndexOf('%'); if (n != -1) { bind = bind.Remove(n, 1); } else { bind = '%' + bind; } } r.x += r.width; EditorGUI.BeginChangeCheck(); GUI.Toggle(r, bind.Contains("#"), "Shift", GeneralStyles.ToolbarToggle); if (EditorGUI.EndChangeCheck() == true) { GUI.FocusControl(null); hasChanged = true; int n = bind.IndexOf('#'); if (n != -1) { bind = bind.Remove(n, 1); } else { bind = '#' + bind; } } r.x += r.width; EditorGUI.BeginChangeCheck(); GUI.Toggle(r, bind.Contains("&"), "Alt", GeneralStyles.ToolbarToggle); if (EditorGUI.EndChangeCheck() == true) { GUI.FocusControl(null); hasChanged = true; int n = bind.IndexOf('&'); if (n != -1) { bind = bind.Remove(n, 1); } else { bind = '&' + bind; } } if (hasChanged == true) { if (string.IsNullOrEmpty(bind) == true) { if (hotkey != null) { settings.hotkeys.Remove(hotkey); } } else { if (hotkey == null) { settings.hotkeys.Add(new CustomHotkeysSettings.MethodHotkey { staticMethod = [email protected] + '.' + shortcut.staticMethod, bind = bind }); } else { hotkey.bind = bind; } } } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5F); } } EditorGUILayout.EndScrollView(); }
protected virtual void OnGUI() { GUILayout.Label(@"In order to get full power from NG Tools, you need to activate licenses to remove limitations. An ""NG Tools Pro"" license will remove all limitations. Any other license will grant full power to only the tool that it is related."); GUILayout.Space(15F); GUILayout.Label("1. Get the invoice.", GeneralStyles.Title1); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Go to your Order History in the Asset Store."); if (GUILayout.Button("Go to Asset Store orders") == true) { Help.BrowseURL("https://assetstore.unity.com/orders"); } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Label("Top-right corner picture in the Asset Store, then \"<b>My Orders</b>\".", GeneralStyles.RichLabel); GUILayout.Space(10F); GUILayout.Label("Find your purchase line, then look for column \"<b>Invoice Number</b>\".", GeneralStyles.RichLabel); GUILayout.Label(@"It might be empty, Unity can require time to generate it. If it is not appearing, please contact them directly."); GUILayout.Space(10F); GUILayout.Label("If you urgently need the license to work, contact me through the following medium:"); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button(Preferences.DiscordContent, GeneralStyles.BigButton, GUILayoutOptionPool.Height(40F)) == true) { Application.OpenURL(Constants.DiscordURL); } if (GUILayout.Button(Preferences.UnityForumContent, GeneralStyles.BigButton, GUILayoutOptionPool.Height(40F)) == true) { Application.OpenURL(Constants.SupportForumUnityThread); } if (GUILayout.Button(LC.G("Preferences_Contact"), GeneralStyles.BigButton, GUILayoutOptionPool.Height(40F)) == true) { ContactFormWizard.Open(ContactFormWizard.Subject.Contact); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(10F); GUILayout.Label("2. Check invoice.", GeneralStyles.Title1); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Go back to Preferences > NG Tools > Licenses."); if (GUILayout.Button("Go") == true) { Utility.ShowPreferencesWindowAt(Constants.PackageTitle, "Licenses"); Preferences.tab = Preferences.Tab.Licenses; } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Write your invoice in the input at the bottom and add it."); if (GUILayout.Button("Highlight") == true) { Utility.ShowPreferencesWindowAt(Constants.PackageTitle, "Licenses"); Preferences.tab = Preferences.Tab.Licenses; XGUIHighlightManager.Highlight(Preferences.Title + ".AddInvoice"); } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(@"Then you need to check it, to ensure NG Tools recognizes it as a valid license."); if (GUILayout.Button("Highlight") == true) { Utility.ShowPreferencesWindowAt(Constants.PackageTitle, "Licenses"); Preferences.tab = Preferences.Tab.Licenses; bool hasUncheckedLicense = false; foreach (License i in NGLicenses.NGLicensesManager.EachInvoices()) { if (i.status == Status.Unknown) { hasUncheckedLicense = true; break; } } if (hasUncheckedLicense == true) { XGUIHighlightManager.Highlight(Preferences.Title + ".CheckLicense"); } else { EditorUtility.DisplayDialog(Constants.PackageTitle, "You must first add invoice prior to check it.", "OK"); } } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10F); GUILayout.Label("3. Activate license.", GeneralStyles.Title1); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(@"If the license is valid, its associated asset will be displayed. Otherwise, it will show ""Invalid"" in grey letters. Now you can activate it."); if (GUILayout.Button("Highlight") == true) { Utility.ShowPreferencesWindowAt(Constants.PackageTitle, "Licenses"); Preferences.tab = Preferences.Tab.Licenses; bool hasValidLicense = false; foreach (License i in NGLicenses.NGLicensesManager.EachInvoices()) { if (i.status == Status.Valid) { hasValidLicense = true; break; } } if (hasValidLicense == true) { XGUIHighlightManager.Highlight(Preferences.Title + ".ActivateLicense"); } else { EditorUtility.DisplayDialog(Constants.PackageTitle, "You must first check an invoice prior to validate it.", "OK"); } } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10F); GUILayout.Label("4. Manage seats.", GeneralStyles.Title1); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(@"You can verifiy seats associated with your licenses. And revoke them as it fits you."); if (GUILayout.Button("Highlight") == true) { Utility.ShowPreferencesWindowAt(Constants.PackageTitle, "Licenses"); Preferences.tab = Preferences.Tab.Licenses; bool hasValidLicense = false; foreach (License i in NGLicenses.NGLicensesManager.EachInvoices()) { if (i.status == Status.Valid) { hasValidLicense = true; break; } } if (hasValidLicense == true) { XGUIHighlightManager.Highlight(Preferences.Title + ".CheckSeats"); } else { EditorUtility.DisplayDialog(Constants.PackageTitle, "You must first check an invoice prior to manage its seats.", "OK"); } } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(@"If you are encountering issues with seats, please contact me directly. If you require a license without the 2 seats limitation, please contact me directly."); if (GUILayout.Button(LC.G("Preferences_Contact"), GUILayoutOptionPool.ExpandHeightTrue) == true) { ContactFormWizard.Open(ContactFormWizard.Subject.Contact); } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5F); EditorGUILayout.HelpBox("A license is an invoice.", MessageType.Info); EditorGUILayout.HelpBox("You can activate a license on 2 seats maximum! \"2 seats\" means 2 computers, implying many projects on those 2 computers, as much as you want.", MessageType.Info); if (this.preferencesWindow != null) { this.preferencesWindow.Repaint(); } }