protected virtual void OnGUI() { if (this.richTextField == null) { this.richTextField = new GUIStyle(GUI.skin.textField); this.richTextField.richText = true; } using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button(LC.G("ImportSettings_Import")) == true) { ImportSettingsWizard.trackObjects.Clear(); try { this.Import(this.root); InternalNGDebug.Log(LC.G("ImportSettings_ImportCompleted")); } catch (Exception ex) { InternalNGDebug.LogException(LC.G("ImportSettings_ImportFailed"), ex); } } } ImportSettingsWizard.trackObjects.Clear(); this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition); { this.DrawNode(this.root); } EditorGUILayout.EndScrollView(); }
protected virtual void OnGUI() { if (this.richTextField == null) { this.richTextField = new GUIStyle(GUI.skin.textField); this.richTextField.richText = true; } this.DrawWizardGUI(); using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button(LC.G("ExportSettings_Export")) == true) { if (SettingsExporter.Export(this.instances, this.root, exportFile) == true) { InternalNGDebug.Log(LC.G("ExportSettings_ExportSuccess")); } else { InternalNGDebug.LogError(LC.G("ExportSettings_ExportFailed")); } } } this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition); this.DrawNode(this.root); EditorGUILayout.EndScrollView(); }
public static BgColorContentRestorer Get(Color color) { BgColorContentRestorer restorer; if (BgColorContentRestorer.cached.TryGetValue(color, out restorer) == false) { restorer = new BgColorContentRestorer(color); BgColorContentRestorer.cached.Add(color, restorer); } else { restorer.Set(color); } return(restorer); }
public static BgColorContentRestorer Get(bool condition, Color color) { return(condition ? BgColorContentRestorer.Get(color) : null); }
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(); }
public BgColorContentAnimator(UnityAction update, float value, float target) : base(update, value, target) { this.restorer = new BgColorContentRestorer(); }
protected virtual void OnGUI() { if (this.GUIOnce == false && Event.current.type == EventType.Repaint) { this.GUIOnce = true; GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); this.ProcessMaxNamespaceWidth(this.types); this.allNamespaceWidth = this.namespaceWidth; this.allNameWidth = this.nameWidth; } GUILayout.BeginHorizontal(GeneralStyles.Toolbar); { EditorGUI.BeginChangeCheck(); using (BgColorContentRestorer.Get(this.temporaryFilterTypes.Count == 0 && string.IsNullOrEmpty(this.filter) == false, Color.red)) { if (Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.Escape) { GUI.FocusControl(null); } else if (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return) { if (this.EnableNullValue == true || this.SelectedType != null) { this.Create(this.SelectedType); } } else if (Event.current.keyCode == KeyCode.Home) { GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); this.SelectedType = null; this.scrollWitnessOnce = false; this.scrollbar.Offset = 0F; this.scrollbar.ClearInterests(); this.Repaint(); } else if (Event.current.keyCode == KeyCode.End) { GUI.FocusControl(null); if (this.EnableCategories == true) { foreach (var pair in this.categories) { this.SelectedType = pair.Value[pair.Value.Count - 1]; } } else if (string.IsNullOrEmpty(this.filter) == true) { this.SelectedType = this.types[this.types.Length - 1]; } else { this.SelectedType = this.displayingTypes[this.displayingTypes.Count - 1]; } this.scrollWitnessOnce = false; this.scrollbar.Offset = float.MaxValue; this.scrollbar.ClearInterests(); this.Repaint(); } else if (Event.current.keyCode == KeyCode.PageUp || Event.current.keyCode == KeyCode.UpArrow) { int shift = Event.current.keyCode == KeyCode.PageUp ? (int)((this.position.height - Constants.SingleLineHeight) / Constants.SingleLineHeight) : 1; if (this.SelectedType == null) { GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); this.scrollbar.Offset = 0F; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); } else if (this.EnableCategories == true) { this.lastTypes.Clear(); this.lastOffsets.Clear(); float shiftOffset = Event.current.keyCode == KeyCode.PageUp ? this.position.height - Constants.SingleLineHeight : Constants.SingleLineHeight; float offset = 0F; float lastHeight = 0F; Type lastType = null; foreach (var pair in this.categories) { for (int i = 0; i < pair.Value.Count; i++) { if (pair.Value[i] == this.SelectedType) { float targetOffset = offset + Constants.SingleLineHeight - shiftOffset; if (i == 0) { targetOffset += GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; } if (this.lastOffsets.Count > 0) { int j = 0; for (j = this.lastOffsets.Count - 1; j >= 0; j--) { if (targetOffset > this.lastOffsets[j]) { if (j + 1 < this.lastOffsets.Count) { lastHeight = this.lastOffsets[j + 1] - this.lastOffsets[j]; } else { lastHeight = offset - this.lastOffsets[j]; } lastType = this.lastTypes[j]; offset = this.lastOffsets[j]; goto bigBreak; } } lastType = this.lastTypes[0]; offset = 0F; } else { GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); lastType = null; offset = 0F; } bigBreak: if (this.SelectedType != lastType) { this.SelectedType = lastType; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); } if (offset < this.scrollbar.Offset) { this.scrollbar.Offset = offset; } else if (offset + lastHeight > this.scrollbar.Offset + this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + offset + lastHeight; } this.Repaint(); return; } this.lastOffsets.Add(offset); this.lastTypes.Add(pair.Value[i]); if (i == 0) { offset += GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; } offset += Constants.SingleLineHeight; } } } else if (string.IsNullOrEmpty(this.filter) == true) { for (int i = 0; i < this.types.Length; i++) { if (this.types[i] == this.SelectedType) { if (i == 0) { GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); this.SelectedType = null; } else { i = Mathf.Max(0, i - shift); this.SelectedType = this.types[i]; } if (i * Constants.SingleLineHeight < this.scrollbar.Offset) { this.scrollbar.Offset = i * Constants.SingleLineHeight; } else if ((i + 1) * Constants.SingleLineHeight - this.scrollbar.Offset > this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + (i + 1) * Constants.SingleLineHeight; } this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } } } else { for (int i = 0; i < this.displayingTypes.Count; i++) { if (this.displayingTypes[i] == this.SelectedType) { if (i == 0) { GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); this.SelectedType = null; } else { i = Mathf.Max(0, i - shift); this.SelectedType = this.displayingTypes[i]; } if (i * Constants.SingleLineHeight < this.scrollbar.Offset) { this.scrollbar.Offset = i * Constants.SingleLineHeight; } else if ((i + 1) * Constants.SingleLineHeight - this.scrollbar.Offset > this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + (i + 1) * Constants.SingleLineHeight; } this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } } } } else if (Event.current.keyCode == KeyCode.PageDown || Event.current.keyCode == KeyCode.DownArrow) { int shift = Event.current.keyCode == KeyCode.PageDown ? (int)((this.position.height - Constants.SingleLineHeight) / Constants.SingleLineHeight) : 1; GUI.FocusControl(null); if (this.EnableCategories == true) { if (this.SelectedType == null) { this.scrollbar.Offset = 0F; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); foreach (var pair in this.categories) { for (int i = 0; i < pair.Value.Count;) { this.SelectedType = pair.Value[i]; return; } } } float shiftOffset = Event.current.keyCode == KeyCode.PageDown ? this.position.height - Constants.SingleLineHeight - Constants.SingleLineHeight : 0F; float offset = 0F; float startOffset = -1F; float lastHeight = 0F; Type lastType = null; foreach (var pair in this.categories) { offset += GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; for (int i = 0; i < pair.Value.Count; i++) { offset += Constants.SingleLineHeight; lastType = pair.Value[i]; if (startOffset > 0F && offset - startOffset > shiftOffset) { if (i == 0) { lastHeight += GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; } lastHeight += Constants.SingleLineHeight; lastType = pair.Value[i]; goto doubleBreak; } if (pair.Value[i] == this.SelectedType) { startOffset = offset; } } } doubleBreak: if (this.SelectedType != lastType) { this.SelectedType = lastType; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); } if (offset - lastHeight < this.scrollbar.Offset) { this.scrollbar.Offset = offset - lastHeight; } else if (offset > this.scrollbar.Offset + this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + offset; } this.Repaint(); return; } else if (string.IsNullOrEmpty(this.filter) == true) { if (this.SelectedType == null && this.types.Length > 0) { this.scrollbar.Offset = 0F; this.SelectedType = this.types[0]; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } for (int i = 0; i < this.types.Length; i++) { if (this.types[i] == this.SelectedType) { i = Mathf.Min(i + shift, this.types.Length - 1); if (i * Constants.SingleLineHeight < this.scrollbar.Offset) { this.scrollbar.Offset = i * Constants.SingleLineHeight; } else if ((i + 1) * Constants.SingleLineHeight - this.scrollbar.Offset > this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + (i + 1) * Constants.SingleLineHeight; } this.SelectedType = this.types[i]; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } } } else { if (this.SelectedType == null && this.displayingTypes.Count > 0) { this.scrollbar.Offset = 0F; this.SelectedType = this.displayingTypes[0]; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } for (int i = 0; i < this.displayingTypes.Count; i++) { if (this.displayingTypes[i] == this.SelectedType) { i = Mathf.Min(i + shift, this.displayingTypes.Count - 1); if (i * Constants.SingleLineHeight < this.scrollbar.Offset) { this.scrollbar.Offset = i * Constants.SingleLineHeight; } else if ((i + 1) * Constants.SingleLineHeight - this.scrollbar.Offset > this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + (i + 1) * Constants.SingleLineHeight; } this.SelectedType = this.displayingTypes[i]; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } } } } } GUI.SetNextControlName(GenericTypesSelectorWizard.TextControlName); this.filter = GUILayout.TextField(this.filter, GeneralStyles.ToolbarSearchTextField); if (GUILayout.Button(GUIContent.none, GeneralStyles.ToolbarSearchCancelButton) == true) { this.filter = string.Empty; } } if (EditorGUI.EndChangeCheck() == true) { this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); if (this.EnableCategories == true) { this.categories.Clear(); this.ProcessMaxNamespaceWidth(this.types); for (int i = 0; i < this.types.Length; i++) { if (CultureInfo.InvariantCulture.CompareInfo.IndexOf(this.types[i].FullName, this.filter, CompareOptions.IgnoreCase) == -1) { continue; } this.AddTypeToCategory(this.types[i]); } } else if (string.IsNullOrEmpty(this.filter) == false) { this.temporaryFilterTypes.Clear(); for (int i = 0; i < this.types.Length; i++) { if (CultureInfo.InvariantCulture.CompareInfo.IndexOf(this.types[i].FullName, this.filter, CompareOptions.IgnoreCase) != -1) { this.temporaryFilterTypes.Add(this.types[i]); } } if (this.temporaryFilterTypes.Count > 0) { List <Type> tmp = this.displayingTypes; this.displayingTypes = this.temporaryFilterTypes; this.temporaryFilterTypes = tmp; // Add a fake value to avoid the input filter turning red. this.temporaryFilterTypes.Add(null); this.ProcessMaxNamespaceWidth(this.displayingTypes); } else { if (this.displayingTypes.Count == 0) { this.displayingTypes.AddRange(this.types); } this.ProcessMaxNamespaceWidth(this.displayingTypes); } } else { this.displayingTypes.Clear(); this.namespaceWidth = this.allNamespaceWidth; this.nameWidth = this.allNameWidth; this.ResizeWindow(); } } EditorGUI.BeginDisabledGroup(this.SelectedType == null && this.EnableNullValue == false); { if (GUILayout.Button(LC.G("Select"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.ExpandWidthFalse) == true) { this.Create(this.SelectedType); } } EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); Rect r = GUILayoutUtility.GetRect(0F, Constants.SingleLineHeight); float rowHeight = r.height; if (Event.current.type == EventType.Repaint) { float totalHeight = 0F; if (this.EnableNullValue == true) { totalHeight = rowHeight; } if (this.EnableCategories == true) { float categoryHeight = GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; foreach (var pair in this.categories) { totalHeight += categoryHeight + (pair.Value.Count * rowHeight); } } else if (string.IsNullOrEmpty(this.filter) == true) { totalHeight += this.types.Length * rowHeight; } else { totalHeight += this.displayingTypes.Count * rowHeight; } this.scrollbar.RealHeight = totalHeight; this.scrollbar.SetPosition(this.position.width - 15F, r.y); this.scrollbar.SetSize(this.position.height - r.y); } this.scrollbar.OnGUI(); Rect bodyRect = this.position; bodyRect.x = 0F; bodyRect.y = r.y; bodyRect.height -= r.y; GUI.BeginGroup(bodyRect); { r.y = -this.scrollbar.Offset; r.width -= this.scrollbar.MaxWidth; if (this.EnableNullValue == true) { this.DrawType(r, null, string.Empty, "Null"); r.y += r.height; } if (this.EnableCategories == true) { float categoryHeight = GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; foreach (var pair in this.categories) { r.height = categoryHeight; GUI.Label(r, pair.Key, GeneralStyles.BigCenterText); r.y += r.height; r.height = rowHeight; for (int i = 0; i < pair.Value.Count; i++) { if (this.scrollWitnessOnce == true && r.y + r.height <= 0) { r.y += r.height; continue; } this.DrawType(r, pair.Value[i], pair.Value[i].Namespace, pair.Value[i].Name); r.y += r.height; if (this.scrollWitnessOnce == true && r.y > this.scrollbar.MaxHeight) { break; } } } } else if (string.IsNullOrEmpty(this.filter) == true) { for (int i = 0; i < this.types.Length; i++) { if (this.scrollWitnessOnce == true && r.y + r.height <= 0) { r.y += r.height; continue; } this.DrawType(r, this.types[i], this.types[i].Namespace, this.types[i].Name); r.y += r.height; if (this.scrollWitnessOnce == true && r.y > this.scrollbar.MaxHeight) { break; } } } else { for (int i = 0; i < this.displayingTypes.Count; i++) { if (this.scrollWitnessOnce == true && r.y + r.height <= 0) { r.y += r.height; continue; } this.DrawType(r, this.displayingTypes[i], this.displayingTypes[i].Namespace, this.displayingTypes[i].Name); r.y += r.height; if (this.scrollWitnessOnce == true && r.y > this.scrollbar.MaxHeight) { break; } } } } GUI.EndGroup(); }
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(); }