private static void OnGUIInputs() { ConsoleSettings settings = HQ.Settings.Get <ConsoleSettings>(); for (int n = 0, i = 0; i < settings.inputsManager.groups.Count; ++i, ++n) { if (GUILayout.Toggle(i == ConsoleSettingsEditor.selectedInputsGroup, LC.G("InputGroup_" + settings.inputsManager.groups[i].name), ConsoleSettingsEditor.menuButtonStyle) == true) { ConsoleSettingsEditor.selectedInputsGroup = i; } } if (ConsoleSettingsEditor.selectedInputsGroup < settings.inputsManager.groups.Count) { ConsoleSettingsEditor.inputScrollPosition = EditorGUILayout.BeginScrollView(ConsoleSettingsEditor.inputScrollPosition); { for (int n = 0, j = 0; j < settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands.Count; ++j, ++n) { while (n >= ConsoleSettingsEditor.testInputAnimationFeedback.Count) { var af = new AnimFloat(0F, EditorWindow.focusedWindow.Repaint); af.speed = 1F; af.target = 0F; ConsoleSettingsEditor.testInputAnimationFeedback.Add(new GUITimer(EditorWindow.focusedWindow.Repaint, Constants.CheckFadeoutCooldown, 0F)); } if (settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands[j].Check() == true) { ConsoleSettingsEditor.testInputAnimationFeedback[n].Start(); ConsoleSettingsEditor.testInputAnimationFeedback[n].af.valueChanged.RemoveAllListeners(); ConsoleSettingsEditor.testInputAnimationFeedback[n].af.valueChanged.AddListener(EditorWindow.focusedWindow.Repaint); } if (ConsoleSettingsEditor.testInputAnimationFeedback[n].Value > 0F) { using (ColorContentRestorer.Get(Color.Lerp(GUI.contentColor, ConsoleSettingsEditor.HighlightInput, ConsoleSettingsEditor.testInputAnimationFeedback[n].Value))) ConsoleSettingsEditor.DrawInputCommand(settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands[j]); } else { ConsoleSettingsEditor.DrawInputCommand(settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands[j]); } } GUILayout.Space(10F); } EditorGUILayout.EndScrollView(); } }
public override void OnGUI() { using (ColorContentRestorer.Get(this.methodInfo == null, Color.red)) { if (string.IsNullOrEmpty(this.alias) == false) { this.content.text = this.alias; } else { this.content.text = this.methodInfo != null ? this.methodInfo.Name : "Method Unknown"; } if (GUILayout.Button(this.content, GUILayoutOptionPool.Height(this.hub.height)) == true) { this.methodInfo.Invoke(null, null); } } }
protected virtual void OnGUI() { List <EntryRef> list; if (string.IsNullOrEmpty(this.keywords) == true && this.filterInstances.Count == 0) { list = NGSpotlightWindow.lastUsed; } else { list = this.results; } Rect r = new Rect(0F, 0F, this.position.width, 18F); if (this.focusTextfieldOnce == false && Event.current.type == EventType.Repaint) { this.focusTextfieldOnce = true; GUI.FocusControl("content"); EditorGUIUtility.editingTextField = true; } if (Event.current.type == EventType.MouseMove) { this.Repaint(); } else if (Event.current.type == EventType.ValidateCommand) { if (Event.current.commandName == "SelectAll" || Event.current.commandName == "Copy" || Event.current.commandName == "Paste" || Event.current.commandName == "Cut") { this.displayHotkeyOnControlPressed = false; } } else if (Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.LeftControl || Event.current.keyCode == KeyCode.RightControl) { if (this.consummedKeydown == false) { this.consummedKeydown = true; this.displayHotkeyOnControlPressed = !this.displayHotkeyOnControlPressed; this.Repaint(); } } else if (this.displayHotkeyOnControlPressed == true && ((Event.current.keyCode >= KeyCode.Alpha1 && Event.current.keyCode <= KeyCode.Alpha9) || (Event.current.keyCode >= KeyCode.Keypad1 && Event.current.keyCode <= KeyCode.Keypad9))) { int n; if (Event.current.keyCode >= KeyCode.Alpha1 && Event.current.keyCode <= KeyCode.Alpha9) { n = (int)(Event.current.keyCode - KeyCode.Alpha1); } else { n = (int)(Event.current.keyCode - KeyCode.Keypad1); } EntryRef er = list[n]; List <IDrawableElement> registry = NGSpotlightWindow.entries[er.key]; if (er.i < registry.Count) { registry[er.i].Execute(this, er); this.Close(); Event.current.Use(); } } else if (Event.current.character == ':' || Event.current.keyCode == KeyCode.Space) { if (this.selectedFilter >= 0 || this.selectedEntry >= 0) { this.selectedFilter = -1; this.selectedEntry = -1; this.focusTextfieldOnce = false; } } else if (Event.current.keyCode == KeyCode.Escape) { this.Close(); Event.current.Use(); } else if (Event.current.keyCode == KeyCode.Delete) { if (this.selectedFilter >= 0) { this.RemoveFilterInstance(this.filterInstances[this.selectedFilter]); while (this.selectedFilter >= this.filterInstances.Count) { --this.selectedFilter; } if (this.filterInstances.Count == 0) { this.focusTextfieldOnce = false; } } } else if (Event.current.keyCode == KeyCode.Backspace) { if (Event.current.control == true) { this.displayHotkeyOnControlPressed = false; } if (this.selectedEntry == -1 && this.keywords.Length == 0 && this.filterInstances.Count > 0) { if (this.selectedFilter == -1) { this.selectedFilter = this.filterInstances.Count - 1; } else if (this.selectedFilter >= 0) { this.RemoveFilterInstance(this.filterInstances[this.selectedFilter]); while (this.selectedFilter >= this.filterInstances.Count) { --this.selectedFilter; } if (this.filterInstances.Count == 0) { this.focusTextfieldOnce = false; } } GUI.FocusControl(null); } } else if (Event.current.keyCode == KeyCode.LeftArrow) { if (Event.current.control == true) { this.displayHotkeyOnControlPressed = false; } if (this.selectedEntry == -1 && this.keywords.Length == 0 && this.filterInstances.Count > 0) { if (this.selectedFilter == -1) { this.selectedFilter = this.filterInstances.Count - 1; } else if (this.selectedFilter > 0) { --this.selectedFilter; } GUI.FocusControl(null); } } else if (Event.current.keyCode == KeyCode.RightArrow) { if (Event.current.control == true) { this.displayHotkeyOnControlPressed = false; } if (this.selectedEntry == -1 && this.keywords.Length == 0 && this.filterInstances.Count > 0) { if (this.selectedFilter < this.filterInstances.Count - 1) { ++this.selectedFilter; } else if (this.selectedFilter == this.filterInstances.Count - 1) { this.selectedFilter = -1; this.focusTextfieldOnce = false; } } } else if (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter) { if (list.Count > 0) { int n = this.selectedEntry; if (n == -1) { if (EditorGUIUtility.editingTextField == false) { return; } n = 0; } EntryRef er = list[n]; List <IDrawableElement> registry = NGSpotlightWindow.entries[er.key]; if (er.i < registry.Count) { registry[er.i].Execute(this, er); this.Close(); Event.current.Use(); } } } else if (Event.current.keyCode == KeyCode.DownArrow) { if (this.selectedEntry + 1 < list.Count) { if (GUI.GetNameOfFocusedControl() == "content") { GUI.FocusControl(null); } this.selectedFilter = -1; this.SelectEntry(this.selectedEntry + 1); this.ClampScrollbarOffsetToSelectedEntry(); Event.current.Use(); } } else if (Event.current.keyCode == KeyCode.UpArrow) { if (this.selectedEntry >= 0) { this.selectedFilter = -1; this.SelectEntry(this.selectedEntry - 1); this.ClampScrollbarOffsetToSelectedEntry(); Event.current.Use(); } } else if (Event.current.keyCode == KeyCode.PageUp) { if (this.selectedEntry >= 0) { this.selectedFilter = -1; if (this.selectedEntry > 1) { this.SelectEntry(Mathf.Max(0, this.selectedEntry - Mathf.FloorToInt((this.position.height - 18F) / NGSpotlightWindow.RowHeight))); } else { this.SelectEntry(-1); } this.ClampScrollbarOffsetToSelectedEntry(); Event.current.Use(); } } else if (Event.current.keyCode == KeyCode.PageDown) { if (this.selectedEntry + 1 < list.Count) { this.selectedFilter = -1; if (GUI.GetNameOfFocusedControl() == "content") { GUI.FocusControl(null); } this.SelectEntry(Mathf.Min(list.Count - 1, this.selectedEntry + Mathf.CeilToInt((this.position.height - 18F) / NGSpotlightWindow.RowHeight))); this.ClampScrollbarOffsetToSelectedEntry(); Event.current.Use(); } } else if (Event.current.keyCode == KeyCode.Home && GUI.GetNameOfFocusedControl() != "content") { this.selectedFilter = -1; this.SelectEntry(-1); this.scrollbar.Offset = 0F; Event.current.Use(); } else if (Event.current.keyCode == KeyCode.End && GUI.GetNameOfFocusedControl() != "content") { this.selectedFilter = -1; this.SelectEntry(list.Count - 1); this.scrollbar.Offset = -this.scrollbar.MaxHeight + (this.selectedEntry + 1) * (NGSpotlightWindow.RowHeight + NGSpotlightWindow.Spacing) - NGSpotlightWindow.Spacing; Event.current.Use(); } } else if (Event.current.type == EventType.KeyUp) { this.consummedKeydown = false; //this.displayHotkeyOnControlPressed = Event.current.control; this.Repaint(); } if (this.filterInstances.Count > 0) { for (int i = 0; i < this.filterInstances.Count; i++) { using (BgColorContentRestorer.Get(this.selectedFilter == i, Color.green)) { r.width = this.filterInstances[i].GetWidth(); this.filterInstances[i].OnGUI(r, this); r.x += r.width + 2F; } } r.width = this.position.width - r.x; } r.xMax -= NGSpotlightWindow.DropdownWidth; EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("content"); this.keywords = EditorGUI.TextField(r, this.keywords); if (EditorGUI.EndChangeCheck() == true) { this.RefreshResult(); } if (string.IsNullOrEmpty(this.keywords) == true) { GUI.enabled = false; r.x += 4F; GUI.Label(r, NGSpotlightWindow.KeywordsPlaceholder); r.x -= 4F; GUI.enabled = true; } r.xMin += r.width; r.width = NGSpotlightWindow.DropdownWidth; if (GUI.Button(r, "", GeneralStyles.ToolbarDropDown) == true) { GenericMenu menu = new GenericMenu(); GenericMenu.MenuFunction rawExport = (this.results.Count > 0) ? new GenericMenu.MenuFunction(this.ExportRawResults) : null; GenericMenu.MenuFunction exportWithContext = (this.results.Count > 0) ? new GenericMenu.MenuFunction(this.ExportResultsWithContext) : null; menu.AddItem(new GUIContent("Raw export"), false, rawExport); menu.AddItem(new GUIContent("Export with context"), false, exportWithContext); menu.AddItem(new GUIContent("Settings"), false, this.OpenSettings); menu.DropDown(r); } if (GUI.GetNameOfFocusedControl() == "content") { this.selectedFilter = -1; this.selectedEntry = -1; } r.x = 0F; r.y += r.height; r.width = this.position.width; if (this.error.Count > 0) { for (int i = 0; i < this.error.Count; i++) { Utility.content.text = this.error[i]; // Helpbox style does not calculate the height correctly. r.height = Mathf.Max(NGSpotlightWindow.RowHeight, EditorStyles.helpBox.CalcHeight(Utility.content, r.width - 50F)); // Reduce the width to ensure we display everything with a bit of luck. EditorGUI.HelpBox(r, this.error[i], MessageType.Warning); r.y += r.height; } } if (this.keywords.Length > 0 && this.keywords[0] == ':' && this.IsValidFilter() == false) { r.height = 16F; using (LabelWidthRestorer.Get(60F)) { for (int i = 0; i < this.availableFilters.Count; i++) { EditorGUIUtility.AddCursorRect(r, MouseCursor.Link); if (Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition) == true) { if (this.availableFilters[i].key.Contains("=") == false && this.availableFilters[i].key.Contains("{") == false) { this.keywords = this.availableFilters[i].key + ' '; } else { this.keywords = this.availableFilters[i].key; } this.RefreshResult(); GUI.FocusControl(null); this.focusTextfieldOnce = false; this.Repaint(); Event.current.Use(); } if (this.availableFilters[i].icon != null) { using (LabelWidthRestorer.Get(80F - 16F)) { Rect iconR = r; r.xMin += 16F; EditorGUI.LabelField(r, this.availableFilters[i].key, this.availableFilters[i].description); iconR.width = iconR.height; GUI.DrawTexture(iconR, this.availableFilters[i].icon, ScaleMode.ScaleToFit); r.xMin -= 16F; } } else { using (LabelWidthRestorer.Get(80F)) { EditorGUI.LabelField(r, this.availableFilters[i].key, this.availableFilters[i].description); } } r.y += r.height + 2F; } } EditorGUI.HelpBox(new Rect(0F, this.position.height - NGSpotlightWindow.RowHeight, this.position.width, NGSpotlightWindow.RowHeight), "Add a space to validate the filter.", MessageType.Info); } else { r.height = NGSpotlightWindow.RowHeight; this.scrollbar.ClearInterests(); if (this.selectedEntry != -1) { this.scrollbar.AddInterest(this.selectedEntry * (NGSpotlightWindow.RowHeight + NGSpotlightWindow.Spacing) + NGSpotlightWindow.RowHeight * .5F, Color.yellow); } this.scrollbar.RealHeight = list.Count * (NGSpotlightWindow.RowHeight + NGSpotlightWindow.Spacing) - NGSpotlightWindow.Spacing; this.scrollbar.SetPosition(this.position.width - 15F, r.y); this.scrollbar.SetSize(this.position.height - r.y); this.scrollbar.OnGUI(); GUI.BeginClip(new Rect(0F, r.y, this.position.width, this.position.height - r.y)); { r.y = -this.scrollbar.Offset; r.width -= this.scrollbar.MaxWidth; for (int i = 0; i < list.Count; i++) { if (r.y + r.height <= 0) { r.y += r.height + NGSpotlightWindow.Spacing; continue; } List <IDrawableElement> registry; if (NGSpotlightWindow.entries.TryGetValue(list[i].key, out registry) == true) { if (list[i].i < registry.Count) { NGSpotlightWindow.entries[list[i].key][list[i].i].OnGUI(r, this, list[i], i); if (this.displayHotkeyOnControlPressed == true && i < 9) { Rect numberR = r; numberR.width = numberR.height; EditorGUI.DrawRect(numberR, Color.cyan * .6F); using (ColorContentRestorer.Get(Color.black)) { GUI.Label(numberR, (i + 1).ToCachedString(), GeneralStyles.MainTitle); } } } else { list.RemoveAt(i--); } } else { list.RemoveAt(i--); } r.y += r.height + NGSpotlightWindow.Spacing; if (r.y > this.scrollbar.MaxHeight) { break; } } } GUI.EndClip(); } }
public override Rect DrawOptions(Rect r) { GeneralSettings general = HQ.Settings.Get <GeneralSettings>(); float maxWidth = r.xMax; EditorGUI.BeginChangeCheck(); if (this.lastLogCount != this.logCount) { this.lastLogCount = this.logCount; this.logContent.text = this.logCount.ToString(); } r.height = Constants.SingleLineHeight; r.width = general.MenuButtonStyle.CalcSize(this.logContent).x; this.displayLog = GUI.Toggle(r, this.displayLog, this.logContent, general.MenuButtonStyle); r.x += r.width; if (this.lastWarningCount != this.warningCount) { this.lastWarningCount = this.warningCount; this.warningContent.text = this.warningCount.ToString(); } r.width = general.MenuButtonStyle.CalcSize(this.warningContent).x; this.displayWarning = GUI.Toggle(r, this.displayWarning, this.warningContent, general.MenuButtonStyle); r.x += r.width; if (this.lastErrorCount != this.errorCount) { this.lastErrorCount = this.errorCount; this.errorContent.text = this.errorCount.ToString(); } r.width = general.MenuButtonStyle.CalcSize(this.errorContent).x; this.displayError = GUI.Toggle(r, this.displayError, this.errorContent, general.MenuButtonStyle); r.x += r.width; if (general.differentiateException == true) { if (this.lastExceptionCount != this.exceptionCount) { this.lastExceptionCount = this.exceptionCount; this.exceptionContent.text = this.exceptionCount.ToString(); } r.width = general.MenuButtonStyle.CalcSize(this.exceptionContent).x; using (ColorContentRestorer.Get(ConsoleConstants.ExceptionFoldoutColor)) { this.displayException = GUI.Toggle(r, this.displayException, this.exceptionContent, general.MenuButtonStyle); } r.x += r.width; } // Update Unity Console only if required. if (EditorGUI.EndChangeCheck() == true) { this.RefreshFilteredRows(); this.OnOptionAltered(); Utility.RepaintConsoleWindow(); } r.width = maxWidth - r.x; return(r); }
public virtual Rect DrawOptions(Rect r) { GeneralSettings settings = HQ.Settings.Get <GeneralSettings>(); float xMax = r.xMax; r.height = Constants.SingleLineHeight; if (HQ.Settings.Get <MainModuleSettings>().displayClearStreamButton == true) { Utility.content.text = LC.G("Clear"); r.width = settings.MenuButtonStyle.CalcSize(Utility.content).x; if (GUI.Button(r, Utility.content, settings.MenuButtonStyle) == true) { this.ClearStream(); } r.x += r.width; } EditorGUI.BeginChangeCheck(); if (this.lastLogCount != this.logCount) { this.lastLogCount = this.logCount; this.logContent.text = this.logCount.ToString(); } r.width = settings.MenuButtonStyle.CalcSize(this.logContent).x; this.displayLog = GUI.Toggle(r, this.displayLog, this.logContent, settings.MenuButtonStyle); r.x += r.width; if (this.lastWarningCount != this.warningCount) { this.lastWarningCount = this.warningCount; this.warningContent.text = this.warningCount.ToString(); } r.width = settings.MenuButtonStyle.CalcSize(this.warningContent).x; this.displayWarning = GUI.Toggle(r, this.displayWarning, this.warningContent, settings.MenuButtonStyle); r.x += r.width; if (this.lastErrorCount != this.errorCount) { this.lastErrorCount = this.errorCount; this.errorContent.text = this.errorCount.ToString(); } r.width = settings.MenuButtonStyle.CalcSize(this.errorContent).x; this.displayError = GUI.Toggle(r, this.displayError, this.errorContent, settings.MenuButtonStyle); r.x += r.width; if (HQ.Settings.Get <GeneralSettings>().differentiateException == true) { if (this.lastExceptionCount != this.exceptionCount) { this.lastExceptionCount = this.exceptionCount; this.exceptionContent.text = this.exceptionCount.ToString(); } r.width = settings.MenuButtonStyle.CalcSize(this.exceptionContent).x; using (ColorContentRestorer.Get(ConsoleConstants.ExceptionFoldoutColor)) { this.displayException = GUI.Toggle(r, this.displayException, this.exceptionContent, settings.MenuButtonStyle); } r.x += r.width; } this.consumeLogContent.tooltip = LC.G("StreamLog_ConsumeLogTooltip"); r.width = 30F; this.consumeLog = GUI.Toggle(r, this.consumeLog, this.consumeLogContent, settings.MenuButtonStyle); r.x += r.width; r.width = xMax - r.x; // Update Unity Console only if required. if (EditorGUI.EndChangeCheck() == true) { this.RefreshFilteredRows(); this.OnOptionAltered(); Utility.RepaintConsoleWindow(); } return(r); }
public override object OnGUI(Rect r, object instance) { r.height = Constants.SingleLineHeight; --EditorGUI.indentLevel; r.x += 3F; if (instance == null) { EditorGUI.BeginChangeCheck(); EditorGUI.Foldout(r, false, this.label + " (Null)", false); if (EditorGUI.EndChangeCheck() == true) { GUI.changed = false; } } else { EditorGUI.BeginChangeCheck(); this.isExpanded = EditorGUI.Foldout(r, this.isExpanded, this.label, true); if (EditorGUI.EndChangeCheck() == true) { NGEditorPrefs.SetBool(path, this.isExpanded); GUI.changed = false; } } r.x -= 3F; ++EditorGUI.indentLevel; if (this.isExpanded == true) { if (instance != null) { this.InitMembers(); try { ++EditorGUI.indentLevel; for (int i = 0; i < this.members.Length; i++) { r.y += r.height + 2F; if (this.members[i].exception != null) { r.height = 16F; using (ColorContentRestorer.Get(Color.red)) EditorGUI.LabelField(r, this.members[i].fieldModifier.Name, "Property raised an exception"); continue; } try { r.height = this.members[i].typeDrawer.GetHeight(this.members[i].fieldModifier.GetValue(instance)); if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true && Event.current.button == 1) { NGStaticInspectorWindow.forceMemberEditable = this.members[i]; EditorWindow window = EditorWindow.mouseOverWindow; if (window != null) { window.Repaint(); } Utility.RegisterIntervalCallback(() => { NGStaticInspectorWindow.forceMemberEditable = null; }, NGStaticInspectorWindow.ForceMemberEditableTickDuration, 1); } bool enabled = GUI.enabled; GUI.enabled = !(!this.members[i].isEditable && NGStaticInspectorWindow.forceMemberEditable != this.members[i]); EditorGUI.BeginChangeCheck(); object value = this.members[i].typeDrawer.OnGUI(r, this.members[i].fieldModifier.GetValue(instance)); if (EditorGUI.EndChangeCheck() == true) { if (this.members[i].isEditable == true) { this.members[i].fieldModifier.SetValue(instance, value); } else { GUI.changed = false; } } GUI.enabled = enabled; } catch (Exception ex) { this.members[i].exception = ex; } } } finally { --EditorGUI.indentLevel; } } } return(instance); }
protected virtual void OnGUI() { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { this.showTypes = GUILayout.Toggle(this.showTypes, "", GeneralStyles.ToolbarDropDown, GUILayoutOptionPool.Width(20F)); EditorGUI.BeginChangeCheck(); this.searchKeywords = EditorGUILayout.TextField(this.searchKeywords, GeneralStyles.ToolbarSearchTextField, GUILayoutOptionPool.ExpandWidthTrue); if (EditorGUI.EndChangeCheck() == true) { this.showTypes = true; this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' '); this.RefreshFilter(); } if (GUILayout.Button("", GeneralStyles.ToolbarSearchCancelButton) == true) { this.searchKeywords = string.Empty; this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' '); GUI.FocusControl(null); this.RefreshFilter(); } } EditorGUILayout.EndHorizontal(); if (this.errorPopup.exception != null) { this.errorPopup.OnGUILayout(); } if (this.typeNameStyle == null) { this.typeNameStyle = new GUIStyle(EditorStyles.label); this.typeNameStyle.alignment = TextAnchor.MiddleLeft; this.typeNameStyle.fontSize = 15; } this.bodyRect = GUILayoutUtility.GetLastRect(); this.bodyRect.y += this.bodyRect.height; if (this.tabTypes.Count > 0 && NGStaticInspectorWindow.staticTypes != null) { float totalWidth = -NGStaticInspectorWindow.Spacing; for (int i = 0; i < this.tabTypes.Count; i++) { Utility.content.text = NGStaticInspectorWindow.staticTypes[this.tabTypes[i]].Name; totalWidth += GeneralStyles.ToolbarButton.CalcSize(Utility.content).x + NGStaticInspectorWindow.Spacing; } this.scrollPositionTabs.allowedMouseArea = new Rect(0F, this.bodyRect.y, this.position.width, 22F); this.scrollPositionTabs.SetPosition(0F, this.bodyRect.y); this.scrollPositionTabs.SetSize(this.position.width); this.scrollPositionTabs.RealWidth = totalWidth; this.scrollPositionTabs.OnGUI(); this.bodyRect.y += this.scrollPositionTabs.MaxHeight; Rect r3 = bodyRect; r3.height = 18F; r3.y += 2F; r3.x = -this.scrollPositionTabs.Offset; for (int i = 0; i < this.tabTypes.Count; i++) { Type type = NGStaticInspectorWindow.staticTypes[this.tabTypes[i]]; string name = type.Name; string @namespace = type.Namespace; Utility.content.text = name; if (@namespace != null) { Utility.content.tooltip = @namespace + '.' + name; } else { Utility.content.tooltip = null; } r3.width = GeneralStyles.ToolbarButton.CalcSize(Utility.content).x; if (GUI.Button(r3, name, GeneralStyles.ToolbarButton) == true) { if (Event.current.button == 2) { this.tabTypes.RemoveAt(i); } this.selectedType = type; Utility.content.tooltip = null; return; } if (this.selectedType == NGStaticInspectorWindow.staticTypes[this.tabTypes[i]]) { Utility.DrawUnfillRect(r3, NGStaticInspectorWindow.SelectedTabOutline); } if (Utility.content.tooltip != null) { TooltipHelper.Label(r3, Utility.content.tooltip); } r3.x += r3.width + NGStaticInspectorWindow.Spacing; } Utility.content.tooltip = null; this.bodyRect.y += 20F + 2F; } float maxY = this.bodyRect.yMax; Rect r = new Rect(); if (this.showTypes == true && NGStaticInspectorWindow.staticTypes != null) { if (Event.current.type == EventType.MouseMove) { this.Repaint(); } this.bodyRect.height = this.position.height - this.bodyRect.y; this.viewRect = new Rect(0F, 0F, 0F, this.CountTypes() * (NGStaticInspectorWindow.Spacing + NGStaticInspectorWindow.TypeHeight) - NGStaticInspectorWindow.Spacing); this.bodyRect.height -= this.contentHeight; if (this.viewRect.height < 100F) { if (this.bodyRect.height > this.viewRect.height) { this.bodyRect.height = this.viewRect.height; } } maxY = this.bodyRect.yMax; this.scrollPositionTypes = GUI.BeginScrollView(this.bodyRect, this.scrollPositionTypes, this.viewRect); { r.width = this.position.width - (viewRect.height > this.bodyRect.height ? 16F : 0F); r.height = NGStaticInspectorWindow.TypeHeight; int i = 0; if (this.viewRect.height > this.bodyRect.height) { i = (int)(this.scrollPositionTypes.y / (NGStaticInspectorWindow.Spacing + r.height)); r.y = i * (NGStaticInspectorWindow.Spacing + r.height); } r.xMin += 5F; foreach (Type type in this.EachType(i--)) { r.height = NGStaticInspectorWindow.TypeHeight; ++i; if (r.y + r.height + NGStaticInspectorWindow.Spacing <= this.scrollPositionTypes.y) { r.y += r.height + NGStaticInspectorWindow.Spacing; continue; } GUI.Box(r, ""); if (Event.current.type == EventType.Repaint) { if (this.selectedType == type) { Utility.DrawUnfillRect(r, NGStaticInspectorWindow.SelectedTypeOutline); } if (r.Contains(Event.current.mousePosition) == true) { r.x -= 2F; r.y -= 2F; r.width += 4F; r.height += 4F; Utility.DrawUnfillRect(r, NGStaticInspectorWindow.HoveredTypeOutline); r.x += 2F; r.y += 2F; r.width -= 4F; r.height -= 4F; } } else if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true) { this.Repaint(); if (Event.current.button != 2) { this.selectedType = type; } if (string.IsNullOrEmpty(this.searchKeywords) == false) { i = this.filteredTypes[i]; } if (Event.current.button != 0 && this.tabTypes.Contains(i) == false) { this.tabTypes.Insert(0, i); } break; } r.height = 22F; GUI.Label(r, type.Name, this.typeNameStyle); r.y += 18F; r.height = 15F; GUI.Label(r, type.Namespace, GeneralStyles.SmallLabel); r.y += 14F + NGStaticInspectorWindow.Spacing; if (r.y - this.scrollPositionTypes.y > this.bodyRect.height) { break; } } r.xMin -= 5F; } GUI.EndScrollView(); this.bodyRect.y = maxY; } bool doubleClickResize = false; if (this.showTypes == true) { float minHeight = GUI.skin.label.CalcHeight(Utility.content, this.bodyRect.width); // Handle splitter bar. this.bodyRect.height = NGStaticInspectorWindow.SplitterHeight; GUI.Box(this.bodyRect, ""); EditorGUIUtility.AddCursorRect(this.bodyRect, MouseCursor.ResizeVertical); if (this.draggingSplitterBar == true && Event.current.type == EventType.MouseDrag) { this.contentHeight = Mathf.Clamp(this.originContentHeight + this.originPositionY - Event.current.mousePosition.y, NGStaticInspectorWindow.MinContentHeight, this.position.height - NGStaticInspectorWindow.MaxContentHeightLeft); Event.current.Use(); } else if (Event.current.type == EventType.MouseDown && this.bodyRect.Contains(Event.current.mousePosition) == true) { this.originPositionY = Event.current.mousePosition.y; this.originContentHeight = this.contentHeight; this.draggingSplitterBar = true; Event.current.Use(); } else if (this.draggingSplitterBar == true && Event.current.type == EventType.MouseUp) { // Auto adjust height on left click or double click. if (this.bodyRect.Contains(Event.current.mousePosition) == true && (Event.current.button == 1 || (this.lastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup && Mathf.Abs(this.originPositionY - Event.current.mousePosition.y) < 5F))) { // 7F of margin, dont know why it is required. CalcHeight seems to give bad result. this.contentHeight = Mathf.Clamp(minHeight + 7F, NGStaticInspectorWindow.MinContentHeight, this.position.height - NGStaticInspectorWindow.MaxContentHeightLeft); doubleClickResize = true; } this.lastClickTime = EditorApplication.timeSinceStartup; this.draggingSplitterBar = false; Event.current.Use(); } this.bodyRect.height = this.position.height - this.bodyRect.y; if (this.bodyRect.height > this.position.height - NGStaticInspectorWindow.MaxContentHeightLeft) { this.contentHeight = this.position.height - NGStaticInspectorWindow.MaxContentHeightLeft; } // Smoothly stay at the minimum if not critical under the critical threshold. if (this.contentHeight < NGStaticInspectorWindow.MinContentHeight) { this.contentHeight = NGStaticInspectorWindow.MinContentHeight; } this.bodyRect.y += NGStaticInspectorWindow.TitleSpacing; } if (this.selectedType != null) { Utility.content.text = this.selectedType.Name; this.bodyRect.height = GeneralStyles.Title1.CalcHeight(Utility.content, this.position.width); bool isPinned = false; Rect starRect = this.bodyRect; starRect.x = 5F; starRect.y += 3F; starRect.width = 12F; starRect.height = 14F; EditorGUIUtility.AddCursorRect(starRect, MouseCursor.Link); for (int i = 0; i < this.tabTypes.Count; i++) { if (NGStaticInspectorWindow.staticTypes[this.tabTypes[i]] == this.selectedType) { isPinned = true; break; } } if (Event.current.type == EventType.MouseDown && starRect.Contains(Event.current.mousePosition) == true) { if (isPinned == true) { for (int i = 0; i < this.tabTypes.Count; i++) { if (NGStaticInspectorWindow.staticTypes[this.tabTypes[i]] == this.selectedType) { this.tabTypes.RemoveAt(i); break; } } } else { for (int i = 0; i < NGStaticInspectorWindow.staticTypes.Length; i++) { if (NGStaticInspectorWindow.staticTypes[i] == this.selectedType) { this.tabTypes.Insert(0, i); break; } } } Event.current.Use(); return; } if (isPinned == true) { Color c = GUI.color; GUI.color = Color.yellow; GUI.DrawTexture(starRect, this.starIcon); GUI.color = c; } else { GUI.DrawTexture(starRect, this.starIcon); } this.bodyRect.xMin += 20F; if (string.IsNullOrEmpty(this.selectedType.Namespace) == false) { GUI.Label(this.bodyRect, this.selectedType.Name + " (" + this.selectedType.Namespace + ")", GeneralStyles.Title1); } else { GUI.Label(this.bodyRect, this.selectedType.Name, GeneralStyles.Title1); } this.bodyRect.xMin -= 20F; this.bodyRect.y += this.bodyRect.height + NGStaticInspectorWindow.TitleSpacing; MemberDrawer[] members = this.GetMembers(this.selectedType); viewRect.height = 0F; try { for (int i = 0; i < members.Length; i++) { try { if (members[i].exception != null) { viewRect.height += NGStaticInspectorWindow.Spacing + 16F; } else { viewRect.height += NGStaticInspectorWindow.Spacing + members[i].typeDrawer.GetHeight(members[i].fieldModifier.GetValue(null)); } } catch (Exception ex) { members[i].exception = ex; } } // Remove last spacing. if (viewRect.height > NGStaticInspectorWindow.Spacing) { viewRect.height -= NGStaticInspectorWindow.Spacing; } if (doubleClickResize == true) { this.contentHeight = Mathf.Clamp(viewRect.height + this.bodyRect.height + NGStaticInspectorWindow.TitleSpacing + NGStaticInspectorWindow.TitleSpacing, NGStaticInspectorWindow.MinContentHeight, this.position.height - NGStaticInspectorWindow.MaxContentHeightLeft); } this.bodyRect.height = this.position.height - this.bodyRect.y; this.scrollPositionMembers = GUI.BeginScrollView(this.bodyRect, this.scrollPositionMembers, viewRect); { r.width = this.position.width - (viewRect.height > this.bodyRect.height ? 16F : 0F) - 8F; r.y = 0F; ++EditorGUI.indentLevel; for (int i = 0; i < members.Length; i++) { if (members[i].exception != null) { r.height = 16F; using (ColorContentRestorer.Get(Color.red)) EditorGUI.LabelField(r, members[i].fieldModifier.Name, "Property raised an exception"); r.y += r.height + NGStaticInspectorWindow.Spacing; continue; } object instance = members[i].fieldModifier.GetValue(null); float height = members[i].typeDrawer.GetHeight(instance); if (r.y + height + NGStaticInspectorWindow.Spacing <= this.scrollPositionMembers.y) { r.y += height + NGStaticInspectorWindow.Spacing; continue; } r.height = height; if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true && Event.current.button == 1) { NGStaticInspectorWindow.forceMemberEditable = members[i]; this.Repaint(); Utility.RegisterIntervalCallback(() => { NGStaticInspectorWindow.forceMemberEditable = null; }, NGStaticInspectorWindow.ForceMemberEditableTickDuration, 1); } EditorGUI.BeginDisabledGroup(!members[i].isEditable && NGStaticInspectorWindow.forceMemberEditable != members[i]); EditorGUI.BeginChangeCheck(); object value = members[i].typeDrawer.OnGUI(r, instance); if (EditorGUI.EndChangeCheck() == true) { if (members[i].isEditable == true) { members[i].fieldModifier.SetValue(null, value); } } EditorGUI.EndDisabledGroup(); r.y += height + NGStaticInspectorWindow.Spacing; if (r.y - this.scrollPositionMembers.y > this.bodyRect.height) { break; } } --EditorGUI.indentLevel; } GUI.EndScrollView(); } catch (Exception ex) { this.errorPopup.exception = ex; } } TooltipHelper.PostOnGUI(); }
public Rect OnGUI(Rect r, bool compact) { // Try to reconnect to last Object. if (this.init == false && EditorApplication.isPlaying == true && string.IsNullOrEmpty(this.lastParent) == false) { GameObject sceneObject = GameObject.Find(this.lastParent); if (sceneObject != null) { this.parent = sceneObject.transform; this.init = true; } } float width = r.width; float includeWidth = width * .33F; if (includeWidth < 95F) { includeWidth = 95F; } GUI.Box(r, string.Empty, GeneralStyles.Toolbar); r.y += 1F; EditorGUI.BeginChangeCheck(); using (LabelWidthRestorer.Get(90F)) { using (ColorContentRestorer.Get(string.IsNullOrEmpty(this.lastParent) == false, HierarchyFilter.ParentBackgroundColor)) { r.width -= includeWidth; if (compact == false) { Utility.content.text = LC.G("ParentObject"); Utility.content.tooltip = this.lastParent; } else { Utility.content.text = string.Empty; } this.parent = EditorGUI.ObjectField(r, Utility.content, this.parent, typeof(Transform), true) as Transform; Utility.content.tooltip = string.Empty; r.x += r.width; } } if (EditorGUI.EndChangeCheck() == true) { if (this.parent != null) { this.lastParent = this.parent.name; } else { this.lastParent = string.Empty; } this.init = true; } r.y -= 1F; // Handle reference destroyed at runtime. if (this.init == true && this.parent == null) { this.init = false; } r.width = includeWidth; if (compact == false) { r.width = 95F; } this.includeChildren = GUI.Toggle(r, this.includeChildren, LC.G("IncludeChildren"), HQ.Settings.Get <GeneralSettings>().MenuButtonStyle); r.x += r.width; if (compact == false) { r.width = includeWidth - r.width; r.y += 1F; //using (LabelWidthRestorer.Get(70F)) { if ( //EditorApplication.isPlaying == true && string.IsNullOrEmpty(this.lastParent) == false) { GUI.Label(r, LC.G("LastParent") + this.lastParent); } } r.y -= 1F; } r.y += r.height + 2F; return(r); }
public Rect OnGUI(Rect r, bool compact) { if (this.logContent == null) { this.Init(); } float width = r.width; GUI.Box(r, string.Empty, GeneralStyles.Toolbar); GeneralSettings settings = HQ.Settings.Get <GeneralSettings>(); if (compact == false) { Utility.content.text = LC.G("AcceptedTypes"); r.width = GUI.skin.label.CalcSize(Utility.content).x + 10F; // Add a small margin for clarity. GUI.Label(r, Utility.content); r.x += r.width; } else { r.width = 0F; } if (settings.differentiateException == true) { r.width = (width - r.width) / 4F; } else { r.width = (width - r.width) / 3F; } EditorGUI.BeginChangeCheck(); GUI.Toggle(r, (this.maskType & (1 << (int)LogType.Log)) != 0, this.logContent, settings.MenuButtonStyle); if (EditorGUI.EndChangeCheck()) { this.maskType = ((int)this.maskType ^ (1 << (int)LogType.Log)); } r.x += r.width; EditorGUI.BeginChangeCheck(); using (BgColorContentRestorer.Get(ConsoleConstants.WarningFoldoutColor)) { GUI.Toggle(r, (this.maskType & (1 << (int)LogType.Warning)) != 0, this.warningContent, settings.MenuButtonStyle); } if (EditorGUI.EndChangeCheck()) { this.maskType = ((int)this.maskType ^ (1 << (int)LogType.Warning)); } r.x += r.width; EditorGUI.BeginChangeCheck(); using (BgColorContentRestorer.Get(ConsoleConstants.ErrorFoldoutColor)) { GUI.Toggle(r, (this.maskType & (1 << (int)LogType.Error)) != 0, this.errorContent, settings.MenuButtonStyle); } if (EditorGUI.EndChangeCheck()) { this.maskType = ((int)this.maskType ^ (1 << (int)LogType.Error)); } r.x += r.width; if (settings.differentiateException == true) { EditorGUI.BeginChangeCheck(); using (ColorContentRestorer.Get(ConsoleConstants.ExceptionFoldoutColor)) { GUI.Toggle(r, (this.maskType & (1 << (int)LogType.Exception)) != 0, this.exceptionContent, settings.MenuButtonStyle); } if (EditorGUI.EndChangeCheck()) { this.maskType = ((int)this.maskType ^ (1 << (int)LogType.Exception)); } } r.y += r.height + 2F; return(r); }
public void Draw(NGAssetFinderWindow window, Rect r) { r.height = Constants.SingleLineHeight; if (this.subMatches.Count > 0) { if (Event.current.type == EventType.Repaint && r.Contains(Event.current.mousePosition) == true) { EditorGUI.DrawRect(r, NGAssetFinderWindow.HighlightBackground); } EditorGUI.BeginChangeCheck(); bool open = EditorGUI.Foldout(r, this.Open, this.nicifiedPath, true); if (EditorGUI.EndChangeCheck() == true) { this.Open = open; } if (this.Open == true) { r.y += r.height; ++EditorGUI.indentLevel; for (int i = 0; i < this.subMatches.Count; i++) { r.height = this.subMatches[i].GetHeight(); this.subMatches[i].Draw(window, r); r.y += r.height; } --EditorGUI.indentLevel; } return; } if (this.arrayIndexes.Count > 0) { if (Event.current.type == EventType.Repaint && r.Contains(Event.current.mousePosition) == true) { EditorGUI.DrawRect(r, NGAssetFinderWindow.HighlightBackground); } EditorGUI.BeginChangeCheck(); bool open = EditorGUI.Foldout(r, this.Open, this.nicifiedPath, true); if (EditorGUI.EndChangeCheck() == true) { this.Open = open; } if (this.Open == true) { r.y += r.height; ++EditorGUI.indentLevel; ICollectionModifier collectionModifier = null; TypeFinder finder = null; try { if (window.canReplace == true) { int j = 0; for (; j < window.typeFinders.array.Length; j++) { if (window.typeFinders.array[j].CanFind(this.type) == true) { finder = window.typeFinders.array[j]; window.typeFinders.BringToTop(j); break; } } if (finder == null) { object rawArray = this.Value; if (rawArray != null) { collectionModifier = NGTools.Utility.GetCollectionModifier(rawArray); } } } for (int j = 0; j < this.arrayIndexes.Count; j++) { if (Event.current.type == EventType.Repaint && r.Contains(Event.current.mousePosition) == true) { EditorGUI.DrawRect(r, NGAssetFinderWindow.HighlightBackground); } if (window.canReplace == false) { using (LabelWidthRestorer.Get(r.width)) { EditorGUI.LabelField(r, "#" + this.arrayIndexes[j].ToCachedString()); } } else { Object reference = null; try { if (finder != null) { reference = finder.Get(this.type, this, this.arrayIndexes[j]); } else { reference = collectionModifier.Get(this.arrayIndexes[j]) as Object; } Utility.content.text = "#" + this.arrayIndexes[j].ToCachedString(); float w = GUI.skin.label.CalcSize(Utility.content).x; using (ColorContentRestorer.Get(window.replaceAsset != null && (collectionModifier != null && collectionModifier.SubType.IsAssignableFrom(window.replaceAsset.GetType()) == false), Color.red)) { EditorGUI.PrefixLabel(r, Utility.content); r.x += w; r.width -= w; try { EditorGUI.BeginChangeCheck(); Object o = EditorGUI.ObjectField(r, reference, window.targetType, AssetMatches.workingAssetMatches.allowSceneObject); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(AssetMatches.workingAssetMatches.origin, "Match assignment"); if (finder != null) { finder.Set(this.type, o, this, this.arrayIndexes[j]); } else { collectionModifier.Set(this.arrayIndexes[j], o); } AssetDatabase.SaveAssets(); } } catch (ExitGUIException) { } r.x -= w; r.width += w; } } catch (Exception ex) { window.errorPopup.exception = ex; EditorGUILayout.LabelField("Error " + this.nicifiedPath + " " + AssetMatches.workingAssetMatches + " /" + reference + "-" + this.instance + " "+ ex.Message + " "+ ex.StackTrace); } } r.y += r.height; } } finally { if (collectionModifier != null) { NGTools.Utility.ReturnCollectionModifier(collectionModifier); } } --EditorGUI.indentLevel; } return; } ++EditorGUI.indentLevel; if (window.canReplace == false) { using (LabelWidthRestorer.Get(r.width)) { r.xMin += (EditorGUI.indentLevel - 1) * 15F; if (typeof(Object).IsAssignableFrom(this.type) == true) { Texture2D image = Utility.GetIcon(this.Value as Object); if (image != null) { Rect r2 = r; r2.width = r2.height; GUI.DrawTexture(r2, image); r.xMin += r2.width; } } GUI.Label(r, this.nicifiedPath); } } else { Object reference = null; try { Utility.content.text = this.nicifiedPath; //Rect r = EditorGUILayout.GetControlRect(false); float w = GUI.skin.label.CalcSize(Utility.content).x; if (typeof(Object).IsAssignableFrom(this.type) == true) { reference = this.Value as Object; Texture2D image = Utility.GetIcon(reference); if (image != null) { Rect r2 = r; r2.xMin += (EditorGUI.indentLevel - 1) * 15F; r2.width = r2.height; GUI.DrawTexture(r2, image); } } else { throw new Exception("Field \"" + this.Name + "\" not an Object."); } using (LabelWidthRestorer.Get(r.xMax)) EditorGUI.BeginDisabledGroup(this.instance is MonoScript || (window.replaceAsset != null && this.type.IsAssignableFrom(window.replaceAsset.GetType()) == false)); { r.x += 1F; EditorGUI.LabelField(r, Utility.content); try { r.x += w; r.width -= w; EditorGUI.BeginChangeCheck(); Object o = EditorGUI.ObjectField(r, reference, this.type, AssetMatches.workingAssetMatches.allowSceneObject); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(AssetMatches.workingAssetMatches.origin, "Match assignment"); this.Value = o; AssetDatabase.SaveAssets(); } } catch (ExitGUIException) { } } EditorGUI.EndDisabledGroup(); } catch (Exception ex) { window.errorPopup.exception = ex; EditorGUILayout.LabelField("Error " + this.nicifiedPath + " " + AssetMatches.workingAssetMatches + " /" + reference + "-" + this.instance + " "+ ex.Message + " "+ ex.StackTrace); } } --EditorGUI.indentLevel; }
public void OnGUI(Rect position) { if (this.previewStyle == null) { this.previewStyle = new GUIStyle(GUI.skin.textArea); this.previewStyle.wordWrap = false; this.previewStyle.fontSize = 8; } Rect viewRect = default(Rect); float previewHeight = 100F; float titleSourcesHeight; Utility.content.text = "Sources (Drag to reorder; click to delete)"; titleSourcesHeight = GeneralStyles.Title1.CalcSize(Utility.content).y; viewRect.height += Constants.SingleLineHeight; // Exporter selector viewRect.height += titleSourcesHeight + 5F; // Sources title + Horizontal Scrollbar if (0 <= this.selectedExporter && this.selectedExporter < this.exporters.Length) { viewRect.height += Constants.SingleLineHeight + 6F + 4F; // Sources viewRect.height += this.exporters[this.selectedExporter].GetHeight() + 2F; // Exporter GUI viewRect.height += Constants.SingleLineHeight; // Preview label if (previewHeight < position.height - viewRect.height) { previewHeight = position.height - viewRect.height; } viewRect.height += previewHeight; // Preview } this.scrollPosition = GUI.BeginScrollView(position, this.scrollPosition, viewRect); { if (viewRect.height > position.height) { position.width -= 16F; } Rect r = position; r.x = 0F; r.y = 0F; r.height = Constants.SingleLineHeight; using (LabelWidthRestorer.Get(70F)) { EditorGUI.BeginChangeCheck(); int e = EditorGUI.Popup(r, LC.G("Exporter"), this.selectedExporter, this.names); if (EditorGUI.EndChangeCheck() == true) { this.selectedExporter = e; this.UpdatePreview(); } r.y += r.height; } r.height = titleSourcesHeight; GUI.Label(r, Utility.content, GeneralStyles.Title1); r.y += titleSourcesHeight + 5F; GUIStyle style = GeneralStyles.ToolbarButton; float totalWidth = LogsExporterDrawer.ExportMargin; for (int i = 0; i < this.usedOutputs.Count; i++) { Utility.content.text = this.usedOutputs[i].GetName(); totalWidth += style.CalcSize(Utility.content).x + LogsExporterDrawer.DoubleExportMargin; // Drag margin } r.width = position.width - LogsExporterDrawer.AddButtonWidth; r.height = Constants.SingleLineHeight + 6F; this.horizontalScrollbar.SetPosition(0F, r.y - 6F); this.horizontalScrollbar.RealWidth = totalWidth + LogsExporterDrawer.DoubleExportMargin; this.horizontalScrollbar.SetSize(r.width); this.horizontalScrollbar.interceiptEvent = false; this.horizontalScrollbar.hasCustomArea = true; this.horizontalScrollbar.allowedMouseArea = r; this.horizontalScrollbar.OnGUI(); Utility.DrawUnfillRect(r, Color.gray * .8F); using (ColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { Utility.content.text = "+"; r.x += LogsExporterDrawer.AddButtonWidth; r.y += 2F; r.xMin = r.xMax - LogsExporterDrawer.AddButtonWidth; if (GUI.Button(r, Utility.content, GeneralStyles.ToolbarButton) == true) { PopupWindow.Show(new Rect(r.x, r.yMax, 0F, 0F), new BrowseLogExportSourcesPopup(this.usedOutputs, this.OnCreate)); } r.y -= 2F; } r.x = 1F; r.width = position.width - LogsExporterDrawer.AddButtonWidth - 2F; GUI.BeginGroup(r); { Rect r2 = r; r2.x = -this.horizontalScrollbar.Offset; r2.y = 2F; r2.height -= 4F; for (int i = 0; i < this.usedOutputs.Count; i++) { Utility.content.text = this.usedOutputs[i].GetName(); r2.width = style.CalcSize(Utility.content).x + LogsExporterDrawer.DoubleExportMargin; if (Event.current.type == EventType.MouseDrag && Utility.position2D != Vector2.zero && DragAndDrop.GetGenericData(Utility.DragObjectDataName) != null && (Utility.position2D - Event.current.mousePosition).sqrMagnitude >= Constants.MinStartDragDistance) { Utility.position2D = Vector2.zero; DragAndDrop.StartDrag("Drag Object"); Event.current.Use(); } else if (Event.current.type == EventType.MouseDown && r2.Contains(Event.current.mousePosition) == true) { Utility.position2D = Event.current.mousePosition; DragAndDrop.PrepareStartDrag(); DragAndDrop.SetGenericData(Utility.DragObjectDataName, i); } else if (Event.current.type == EventType.Repaint && DragAndDrop.GetGenericData(Utility.DragObjectDataName) != null) { int dragIndex = (int)DragAndDrop.GetGenericData(Utility.DragObjectDataName); if (dragIndex == i) { EditorGUI.DrawRect(r2, Color.red * .5F); } else if (r2.Contains(Event.current.mousePosition) == true && DragAndDrop.visualMode == DragAndDropVisualMode.Copy) { bool isPointingBefore = Event.current.mousePosition.x < r2.x + r2.width * .5F; if (i + 1 == dragIndex || (isPointingBefore == true && i - 1 != dragIndex)) { Rect r3 = r2; r3.width = 1F; EditorGUI.DrawRect(r3, Color.yellow); } else if (i - 1 == dragIndex || isPointingBefore == false) { Rect r3 = r2; r3.x += r3.width; r3.width = 1F; EditorGUI.DrawRect(r3, Color.yellow); } } } else if ((Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform) && r2.Contains(Event.current.mousePosition) == true) { int dragIndex = (int)DragAndDrop.GetGenericData(Utility.DragObjectDataName); if (i.Equals(dragIndex) == false) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; } else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } if (Event.current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); bool isPointingBefore = Event.current.mousePosition.x < r2.x + r2.width * .5F; if (i + 1 == dragIndex || (isPointingBefore == true && i - 1 != dragIndex)) { this.usedOutputs.Insert(i, this.usedOutputs[dragIndex]); } else if (i - 1 == dragIndex || isPointingBefore == false) { this.usedOutputs.Insert(i + 1, this.usedOutputs[dragIndex]); } if (i < dragIndex) { this.usedOutputs.RemoveAt(dragIndex + 1); } else { this.usedOutputs.RemoveAt(dragIndex); } this.UpdatePreview(); DragAndDrop.PrepareStartDrag(); } Event.current.Use(); } r2.x += LogsExporterDrawer.ExportMargin; r2.width -= LogsExporterDrawer.DoubleExportMargin; if (GUI.Button(r2, Utility.content.text, style) == true) { this.usedOutputs.RemoveAt(i); this.UpdatePreview(); return; } r2.width += LogsExporterDrawer.DoubleExportMargin; r2.x += r2.width - LogsExporterDrawer.ExportMargin; } } GUI.EndGroup(); if (0 <= this.selectedExporter && this.selectedExporter < this.exporters.Length) { r.x = 0F; r.width = position.width; r.y += r.height + 4F; EditorGUI.BeginChangeCheck(); r.height = this.exporters[this.selectedExporter].GetHeight(); this.exporters[this.selectedExporter].OnGUI(r); r.y += r.height + 2F; if (EditorGUI.EndChangeCheck() == true || string.IsNullOrEmpty(this.preview) == true) { this.UpdatePreview(); } r.height = Constants.SingleLineHeight; GUI.Label(r, this.previewLabel); r.x += 50F; r.width = 50F; EditorGUI.BeginChangeCheck(); this.previewCount = EditorGUI.IntField(r, this.previewCount); if (EditorGUI.EndChangeCheck() == true) { if (this.previewCount < 1) { this.previewCount = 1; } this.UpdatePreview(); } r.y += r.height; r.x = 0F; r.width = position.width; r.height = previewHeight; GUI.TextArea(r, this.preview, this.previewStyle); } } GUI.EndScrollView(); }