private void DrawElement(string input, float halfWidth, Action <string> renamer) { EditorGUILayout.BeginHorizontal(); { TransformedNames names; if (this.cachedNames.TryGetValue(input, out names) == false) { try { names = new TransformedNames(); names.highlighted = this.HighlightPattern(input); names.renamed = this.Rename(input); this.cachedNames.Add(input, names); } catch (Exception ex) { this.errorPopup.exception = ex; names.highlighted = input; names.renamed = "ERROR"; } } GUILayout.Label(names.highlighted, GeneralStyles.RichLabel, GUILayoutOptionPool.Width(halfWidth)); if (GUILayout.Button("->", GUILayoutOptionPool.Width(30F)) == true) { renamer(names.renamed); return; } GUILayout.Label(names.renamed, GUILayoutOptionPool.Width(halfWidth)); } EditorGUILayout.EndHorizontal(); }
private void DebugDrawResent(Packet packet) { if (GUILayout.Button(LC.G("NGInspector_Resend"), GUILayoutOptionPool.Width(60F)) == true) { this.Hierarchy.Client.AddPacket(packet); } }
public override void OnGUI() { if (this.buttonLeft == null) { this.buttonLeft = "ButtonLeft"; this.buttonRight = "ButtonRight"; } EditorGUI.BeginDisabledGroup(!NGNavSelectionWindow.CanSelectPrevious); { if (GUILayout.Button(this.leftContent, this.buttonLeft, GUILayoutOptionPool.Height(this.hub.height)) == true) { NGNavSelectionWindow.SelectPreviousSelection(); } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(!NGNavSelectionWindow.CanSelectNext); { if (GUILayout.Button(this.rightContent, this.buttonRight, GUILayoutOptionPool.Height(this.hub.height)) == true) { NGNavSelectionWindow.SelectNextSelection(); } } EditorGUI.EndDisabledGroup(); }
private static void OnGUIGeneralLog() { LogSettings settings = HQ.Settings.Get <LogSettings>(); ConsoleSettingsEditor.generalLogScrollPosition = EditorGUILayout.BeginScrollView(ConsoleSettingsEditor.generalLogScrollPosition); { ConsoleSettingsEditor.sectionLog.OnGUI(); GUILayout.Space(10F); } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginVertical(GUILayoutOptionPool.Height(16F + 5F * settings.height)); EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); EditorGUILayout.LabelField("Preview :"); EditorGUILayout.EndHorizontal(); ConsoleSettingsEditor.DrawRow(0, 0, false, "A selected row.", ""); ConsoleSettingsEditor.DrawRow(1, 0, false, "A normal even row.", "1"); ConsoleSettingsEditor.DrawRow(2, 1, false, "A warning odd row.", "23"); ConsoleSettingsEditor.DrawRow(3, 2, false, "An error even row.", "456"); ConsoleSettingsEditor.DrawRow(4, 3, false, "An exception odd row.", "7890"); EditorGUILayout.EndVertical(); }
public override void OnGUI() { this.content.text = (string.IsNullOrEmpty(this.alias) == true ? this.menuItem : this.alias); this.content.image = this.image; if (GUILayout.Button(this.content, GUILayoutOptionPool.Height(this.hub.height)) == true) { EditorApplication.ExecuteMenuItem(this.menuItem); } }
public override void OnGUI() { if (this.buttonLeft == null) { this.buttonLeft = "ButtonLeft"; this.buttonRight = "ButtonRight"; } if (this.displayOnlyIcon == true) { if (GUILayout.Button(this.unityModeIcon, this.buttonLeft, GUILayoutOptionPool.Height(this.hub.height), GUILayoutOptionPool.Width(24F)) == true) { NGRemoteHierarchyWindow.FocusUnityWindows(); } Rect r = GUILayoutUtility.GetLastRect(); GUI.DrawTexture(r, this.unityModeIcon.image, ScaleMode.ScaleToFit); if (GUILayout.Button(this.remoteModeIcon, this.buttonRight, GUILayoutOptionPool.Height(this.hub.height), GUILayoutOptionPool.Width(24F)) == true) { foreach (NGRemoteHierarchyWindow window in Utility.EachEditorWindows(typeof(NGRemoteHierarchyWindow))) { window.Focus(); } foreach (NGRemoteWindow window in Utility.EachEditorWindows(typeof(NGRemoteWindow))) { window.Focus(); } } r = GUILayoutUtility.GetLastRect(); GUI.DrawTexture(r, this.remoteModeIcon.image, ScaleMode.ScaleToFit); } else { if (GUILayout.Button(this.unityMode, this.buttonLeft, GUILayoutOptionPool.Height(this.hub.height)) == true) { NGRemoteHierarchyWindow.FocusUnityWindows(); } if (GUILayout.Button(this.remoteMode, this.buttonRight, GUILayoutOptionPool.Height(this.hub.height)) == true) { foreach (NGRemoteHierarchyWindow window in Utility.EachEditorWindows(typeof(NGRemoteHierarchyWindow))) { window.Focus(); } foreach (NGRemoteWindow window in Utility.EachEditorWindows(typeof(NGRemoteWindow))) { window.Focus(); } } } }
protected override void OnGUIConnected() { if (this.projectAssets == null) { if (this.Hierarchy.IsChannelBlocked(this.GetHashCode()) == true) { EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUILayout.Label(GeneralStyles.StatusWheel, GUILayoutOptionPool.Width(20F)); GUILayout.Label("Loading assets..."); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); } return; } Rect viewRect = new Rect(0F, 0F, 0F, this.root.GetHeight()); bodyRect.x = 0F; bodyRect.y = Constants.SingleLineHeight + 2; bodyRect.width = this.position.width; bodyRect.height = this.position.height - bodyRect.y; if (Folder.File.selectedFile != null) { bodyRect.height -= Constants.SingleLineHeight; } float height = bodyRect.y + bodyRect.height; this.scrollPosition = GUI.BeginScrollView(bodyRect, this.scrollPosition, viewRect); { bodyRect.y = 0F; bodyRect.height = Constants.SingleLineHeight; this.root.Draw(bodyRect, true); } GUI.EndScrollView(); if (Folder.File.selectedFile != null) { bodyRect.y = height; EditorGUI.DrawRect(bodyRect, NGRemoteProjectWindow.AssetTypesBackgroundColor); EditorGUI.LabelField(bodyRect, Folder.File.selectedFile.rawTypes[Folder.File.assetIndex]); } if (Event.current.type == EventType.MouseDown) { Folder.File.selectedFile = null; Event.current.Use(); } }
protected override void OnGUIHeader() { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { if (GUILayout.Button("☰", "GV Gizmo DropDown", GUILayoutOptionPool.Width(30F)) == true) { PopupWindow.Show(new Rect(0F, 16F, 0F, 0F), new OptionPopup(this)); } 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(); } if (this.autoLoad == false) { if (this.Hierarchy.inspectableTypes == null) { bool isConnected = this.Hierarchy.IsClientConnected(); EditorGUI.BeginDisabledGroup(!isConnected); if (GUILayout.Button(LC.G("NGProject_Load"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(40F)) == true) { this.Hierarchy.LoadInspectableTypes(this.OnStaticTypesReceived); } XGUIHighlightManager.DrawHighlightLayout(NGRemoteStaticInspectorWindow.Title + ".Load", this); EditorGUI.EndDisabledGroup(); } } } EditorGUILayout.EndHorizontal(); if (this.errorPopup.exception != null) { this.errorPopup.OnGUILayout(); } }
private static void OnGUIGeneralStackTrace() { StackTraceSettings stackTraceSettings = HQ.Settings.Get <StackTraceSettings>(); LogSettings logSettings = HQ.Settings.Get <LogSettings>(); ConsoleSettingsEditor.generalStackTraceScrollPosition = EditorGUILayout.BeginScrollView(ConsoleSettingsEditor.generalStackTraceScrollPosition); { EditorGUI.BeginChangeCheck(); ConsoleSettingsEditor.sectionStackTrace.OnGUI(); if (EditorGUI.EndChangeCheck() == true) { LogConditionParser.cachedFrames.Clear(); LogConditionParser.cachedFramesArrays.Clear(); MainModule.methodsCategories.Clear(); } GUILayout.Space(10F); } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginVertical(GUILayoutOptionPool.Height(16F + 2 * logSettings.height + 8 * Constants.SingleLineHeight)); EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); EditorGUILayout.LabelField("Preview :"); EditorGUILayout.EndHorizontal(); if (stackTraceSettings.skipUnreachableFrame == true) { ConsoleSettingsEditor.DrawStackFrame(0, "Sub Frame.", "Assets/An/Existing/File.cs", true); } else { ConsoleSettingsEditor.DrawStackFrame(0, "Top Frame.", "A/File/Somewhere/That/Does/Not/Exist.cs", false); ConsoleSettingsEditor.DrawStackFrame(1, "Sub Frame.", "Assets/An/Existing/File.cs", true); } ConsoleSettingsEditor.DrawStackFrameCode(1, false, "using UnityEngine;"); ConsoleSettingsEditor.DrawStackFrameCode(2, false, "private static class Foo : Object"); ConsoleSettingsEditor.DrawStackFrameCode(3, false, "{"); ConsoleSettingsEditor.DrawStackFrameCode(4, false, " public internal void Func(Vector2 v)"); ConsoleSettingsEditor.DrawStackFrameCode(5, false, " {"); ConsoleSettingsEditor.DrawStackFrameCode(6, true, " Debug.Log(\"Someting\");"); ConsoleSettingsEditor.DrawStackFrameCode(7, false, " }"); ConsoleSettingsEditor.DrawStackFrameCode(8, false, "}"); EditorGUILayout.EndVertical(); }
protected virtual void OnGUI() { Rect r = this.position; r.x = 0F; r.y = 0F; r.yMax -= 32F; this.drawer.OnGUI(r); r.y += r.height; r.height = 32F; GUILayout.BeginArea(r); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical(); { GUILayout.Space(10F); using (LabelWidthRestorer.Get(95F)) { this.exportFile = NGEditorGUILayout.SaveFileField(LC.G("ExportFilePath"), this.exportFile, string.Empty, string.Empty); } } EditorGUILayout.EndVertical(); GUILayout.Space(10F); EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(this.exportFile)); { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button(LC.G("Export"), GUILayoutOptionPool.Height(30F)) == true) { this.ExportLogs(); } } } EditorGUI.EndDisabledGroup(); } EditorGUILayout.EndHorizontal(); } GUILayout.EndArea(); }
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() { if (this.initialized == false) { // Prevent initialization message after entering play mode. if (Time.frameCount <= 2) { return; } GUILayout.Label(string.Format(LC.G("RequiringConfigurationFile"), NGHubWindow.Title), GeneralStyles.CenterText, GUILayoutOptionPool.Height(this.height)); if (this.dockedAsMenu == false) { GUILayout.BeginHorizontal(); { if (GUILayout.Button(LC.G("ShoWPreferencesWindow")) == true) { Utility.ShowPreferencesWindowAt(Constants.PreferenceTitle); } // Especially for NG Hub, we need to add a way to manually close the window when the dock mode is failing. if (GUILayout.Button("X", GUILayoutOptionPool.Width(16F)) == true) { this.Close(); } } GUILayout.EndHorizontal(); } return; } FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGHubWindow.FreeAdContent); if (Event.current.type == EventType.Repaint) { if (this.backgroundColor.a > 0F) { EditorGUI.DrawRect(new Rect(0F, 0F, this.position.width, this.position.height), this.backgroundColor); } else { EditorGUI.DrawRect(new Rect(0F, 0F, this.position.width, this.position.height), NGHubWindow.DockBackgroundColor); } } EditorGUILayout.BeginHorizontal(GUILayoutOptionPool.Height(this.height)); { if (this.errorPopup.exception != null) { if (this.dockedAsMenu == true) { Rect r = GUILayoutUtility.GetRect(0F, 0F, GUILayoutOptionPool.Width(115F), GUILayoutOptionPool.Height(this.height + 3F)); r.x += 1F; r.y += 1F; this.errorPopup.OnGUIRect(r); } else { this.errorPopup.OnGUILayout(); } } bool isDragging = this.HandleDrop(); bool overflow = false; EventType catchedType = EventType.Used; if (this.components.Count == 0) { if (isDragging == false) { Rect r = this.position; r.x = 1F; r.y = 1F; r.width -= 1F; r.height -= 1F; if (this.dockedAsMenu == true && Event.current.type == EventType.Repaint) { Utility.DrawRectDotted(r, this.position, Color.grey, .02F, 0F); } GUI.Label(r, "Right-click to add Component" + (this.dockedAsMenu == true && Application.platform == RuntimePlatform.OSXEditor? " (Dock mode is buggy under OSX)" : ""), GeneralStyles.CenterText); } } else { Rect miseryRect = default(Rect); int lastMinI = this.extensionWindow != null ? this.extensionWindow.minI : 0; if (this.dockedAsMenu == true && this.extensionWindow != null && this.maxWidth > 0F) { miseryRect = new Rect(this.maxWidth, 0F, this.position.width - this.maxWidth, this.height + 4F); GUI.Label(miseryRect, GUIContent.none); if (miseryRect.Contains(Event.current.mousePosition) == true) { GUIUtility.hotControl = 0; } } for (int i = 0; i < this.components.Count; i++) { // Catch event from the cropped component. if (this.dockedAsMenu == true && Event.current.type != EventType.Repaint && Event.current.type != EventType.Layout && this.extensionWindow != null) { if (this.extensionWindow.minI == i) { // Simulate context click, because MouseUp is used, therefore ContextClick is not sent. if (Event.current.type == EventType.MouseUp && Event.current.button == 1) { catchedType = EventType.ContextClick; } else { catchedType = Event.current.type; } Event.current.Use(); } } EditorGUILayout.BeginHorizontal(); { try { this.components[i].OnGUI(); } catch (Exception ex) { this.errorPopup.exception = ex; } } EditorGUILayout.EndHorizontal(); if (this.dockedAsMenu == true && Event.current.type == EventType.Repaint) { Rect r = GUILayoutUtility.GetLastRect(); if (r.xMax >= this.position.width) { if (this.extensionWindow == null) { this.extensionWindow = ScriptableObject.CreateInstance <NGHubExtensionWindow>(); this.extensionWindow.Init(this); this.extensionWindow.ShowPopup(); this.Repaint(); } this.maxWidth = r.xMin; this.extensionWindow.minI = i; overflow = true; break; } else if (this.position.width - r.xMax <= 16F && i + 1 < this.components.Count) // Prevent drawing next component if the space is obviously too small. { if (this.extensionWindow == null) { this.extensionWindow = ScriptableObject.CreateInstance <NGHubExtensionWindow>(); this.extensionWindow.Init(this); this.extensionWindow.ShowPopup(); this.Repaint(); } this.maxWidth = r.xMax; this.extensionWindow.minI = i + 1; overflow = true; break; } else { this.maxWidth = 0F; } } } if (this.dockedAsMenu == true) { if (this.extensionWindow != null && this.maxWidth > 0F) { if (lastMinI != this.extensionWindow.minI) { this.Repaint(); } // Hide the miserable trick... if (Event.current.type == EventType.Repaint) { if (this.backgroundColor.a > 0F) { EditorGUI.DrawRect(miseryRect, this.backgroundColor); } else { EditorGUI.DrawRect(miseryRect, NGHubWindow.DockBackgroundColor); } } } else { Rect r = GUILayoutUtility.GetLastRect(); r.xMin = r.xMax + 1F; r.width = this.position.width - r.x; r.yMin -= 3F; r.yMax += 3F; if (Event.current.type == EventType.Repaint) { if (this.backgroundColor.a > 0F) { EditorGUI.DrawRect(r, this.backgroundColor); } else { EditorGUI.DrawRect(r, NGHubWindow.DockBackgroundColor); } } } } } if (this.dockedAsMenu == true && Event.current.type == EventType.Repaint && overflow == false && this.extensionWindow != null) { this.extensionWindow.Close(); this.extensionWindow = null; base.Repaint(); } if (Event.current.type == EventType.ContextClick || catchedType == EventType.ContextClick) { this.OpenContextMenu(); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro"); }
protected virtual void OnGUI() { InternalNGDebug.AssertFile(this.hierarchy != null, "ResourcesPicker requires to be created through ResourcesPicker.Init."); if (this.resources == null) { this.hierarchy.GetResources(this.type, out this.resources, out this.ids); if (this.resources == null) { EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUILayout.Label(GeneralStyles.StatusWheel, GUILayoutOptionPool.Width(20F)); EditorGUILayout.LabelField(LC.G("NGHierarchy_ResourcesNotAvailable"), GeneralStyles.WrapLabel); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); return; } else { for (int i = 0; i < this.ids.Length; i++) { if (this.ids[i] == this.initialInstanceID) { this.FitFocusedRowInScreen(i); break; } } } } if (Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.UpArrow) { this.selectedInstanceID = this.GetInstanceIDNeighbour(this.selectedInstanceID, -1); this.SendSelection(this.selectedInstanceID); this.Repaint(); } else if (Event.current.keyCode == KeyCode.DownArrow) { this.selectedInstanceID = this.GetInstanceIDNeighbour(this.selectedInstanceID, 1); this.SendSelection(this.selectedInstanceID); this.Repaint(); } else if (Event.current.keyCode == KeyCode.PageUp) { this.selectedInstanceID = this.GetInstanceIDNeighbour(this.selectedInstanceID, -(Mathf.FloorToInt((this.position.height - (ResourcesPickerWindow.HeaderHeight + ResourcesPickerWindow.HeaderSpace)) / 16))); this.SendSelection(this.selectedInstanceID); this.Repaint(); } else if (Event.current.keyCode == KeyCode.PageDown) { this.selectedInstanceID = this.GetInstanceIDNeighbour(this.selectedInstanceID, Mathf.FloorToInt((this.position.height - (ResourcesPickerWindow.HeaderHeight + ResourcesPickerWindow.HeaderSpace)) / 16)); this.SendSelection(this.selectedInstanceID); this.Repaint(); } else if (Event.current.keyCode == KeyCode.Home) { this.selectedInstanceID = 0; this.SendSelection(this.selectedInstanceID); this.Repaint(); } else if (Event.current.keyCode == KeyCode.End) { this.selectedInstanceID = this.GetInstanceIDFromIndex(this.GetCountResources() - 1, this.ids); this.SendSelection(this.selectedInstanceID); this.Repaint(); } else if (Event.current.keyCode == KeyCode.Escape) { this.SendSelection(this.initialInstanceID); } else if (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter) { this.SendSelection(this.selectedInstanceID); this.Close(); } } GUILayout.BeginHorizontal("ObjectPickerToolbar", GUILayoutOptionPool.Height(ResourcesPickerWindow.HeaderHeight)); { EditorGUI.BeginChangeCheck(); this.searchString = GUILayout.TextField(this.searchString, "SearchTextField"); if (EditorGUI.EndChangeCheck() == true) { this.RefreshFilter(); } if (GUILayout.Button("", string.IsNullOrEmpty(this.searchString) ? "SearchCancelButtonEmpty" : "SearchCancelButton") == true) { this.searchString = string.Empty; this.selectedInstanceID = 0; GUI.FocusControl(null); } } GUILayout.EndHorizontal(); GUILayout.Space(-18F); GUILayout.BeginHorizontal(); { if (GUILayout.Toggle(this.currentTab == 0, "Assets", "ObjectPickerTab") == true) { this.SetTab(0); } for (int i = 0; i < this.tabs.Count; i++) { if (GUILayout.Toggle(this.currentTab == i + 1, this.tabs[i].name, "ObjectPickerTab") == true) { this.SetTab(i + 1); } } GUILayout.FlexibleSpace(); if (this.currentTab == 0) { if (this.hierarchy.IsChannelBlocked(this.type.GetHashCode()) == true) { GUILayout.Label(GeneralStyles.StatusWheel, GUILayoutOptionPool.Width(20F)); this.Repaint(); } else if (GUILayout.Button("Refresh", GUILayoutOptionPool.ExpandWidthFalse) == true) { this.hierarchy.LoadResources(this.type, true); } } } GUILayout.EndHorizontal(); GUILayout.Space(ResourcesPickerWindow.HeaderSpace); this.r.x = 0F; this.r.y = GUILayoutUtility.GetLastRect().yMax + ResourcesPickerWindow.HeaderSpace; this.r.width = this.position.width; this.r.height = this.position.height - this.r.y; float bodyHeight = r.height; if (this.currentTab == 0) { this.resourcesCount = this.GetCountResources() + 1; this.viewRect.height = this.resourcesCount * Constants.SingleLineHeight; this.scrollPosition = GUI.BeginScrollView(this.r, this.scrollPosition, this.viewRect); { this.r.x = 0F; this.r.y = 0F; this.r.height = Constants.SingleLineHeight; int i = 0; foreach (string resource in this.ForResources(this.resources)) { if (this.r.y + this.r.height <= this.scrollPosition.y) { this.r.y += this.r.height; ++i; continue; } int instanceID = this.GetInstanceIDFromIndex(i - 1, this.ids); if (Event.current.type == EventType.Repaint && instanceID == this.selectedInstanceID) { EditorGUI.DrawRect(r, ResourcesPickerWindow.FocusBackgroundColor); } else if (Event.current.type == EventType.Repaint && instanceID == this.initialInstanceID) { EditorGUI.DrawRect(r, ResourcesPickerWindow.InitialBackgroundColor); } if (Event.current.type == EventType.MouseDown && this.r.Contains(Event.current.mousePosition) == true) { if (this.selectedInstanceID == instanceID) { this.Close(); } else { this.selectedInstanceID = instanceID; this.SendSelection(instanceID); } this.Repaint(); Event.current.Use(); } GUI.Label(this.r, resource + " (#" + instanceID + ')'); this.r.y += this.r.height; ++i; if (this.r.y - this.scrollPosition.y > bodyHeight) { break; } } } GUI.EndScrollView(); } else { this.tabs[this.currentTab - 1].OnGUI(this.r); } }
public override void OnGUI() { if (this.cs == null) { this.cs = new GUIContent("Ab", LC.G("CaseSensitive")); this.regex = new GUIContent("R*", LC.G("RegularExpressions")); this.whole = new GUIContent("|abc|", LC.G("WholeMatch")); } GUILayout.BeginHorizontal(GeneralStyles.Toolbar); { using (LabelWidthRestorer.Get(120F)) { this.searchMode = (SearchMode)EditorGUILayout.EnumPopup(this.searchMode, GeneralStyles.ToolbarDropDown, GUILayoutOptionPool.Width(100F)); } EditorGUI.BeginChangeCheck(); GUILayout.Toggle(this.caseSensitive == CompareOptions.IgnoreCase, this.cs, GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(30F)); if (EditorGUI.EndChangeCheck() == true) { if (this.caseSensitive == CompareOptions.IgnoreCase) { this.caseSensitive = CompareOptions.None; } else { this.caseSensitive = CompareOptions.IgnoreCase; } } EditorGUI.BeginChangeCheck(); GUILayout.Toggle(this.wholeWord, this.whole, GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(40F)); if (EditorGUI.EndChangeCheck() == true) { this.wholeWord = !this.wholeWord; } EditorGUI.BeginChangeCheck(); GUILayout.Toggle(this.useRegex, this.regex, GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(30F)); if (EditorGUI.EndChangeCheck() == true) { this.useRegex = !this.useRegex; this.CheckRegex(); } using (LabelWidthRestorer.Get(70F)) { using (BgColorContentRestorer.Get(string.IsNullOrEmpty(this.regexSyntaxError) == false, Color.red)) { EditorGUI.BeginChangeCheck(); this.keyword = EditorGUILayout.TextField(this.keyword, GeneralStyles.ToolbarSearchTextField); if (EditorGUI.EndChangeCheck() == true) { this.CheckRegex(); } if (GUILayout.Button(GUIContent.none, GeneralStyles.ToolbarSearchCancelButton) == true) { this.keyword = string.Empty; this.regexSyntaxError = null; } } } } GUILayout.EndHorizontal(); }
protected virtual void OnGUI() { if (this.source == null || this.source.Initialized == false) { return; } if (Event.current.type == EventType.Repaint) { if (this.source.backgroundColor.a > 0F) { EditorGUI.DrawRect(new Rect(0F, 0F, this.position.width, this.position.height), this.source.backgroundColor); } else { EditorGUI.DrawRect(new Rect(0F, 0F, this.position.width, this.position.height), NGHubWindow.DockBackgroundColor); } } if (this.overflowing == true) { Rect r = this.position; r.y = 5F; r.x = r.width - 20F; r.width = 20F; if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && r.Contains(Event.current.mousePosition) == true) { NGHubDropdownWindow[] windows = Resources.FindObjectsOfTypeAll <NGHubDropdownWindow>(); if (windows.Length > 0) { for (int i = 0; i < windows.Length; i++) { windows[i].Close(); } } else if (NGHubDropdownWindow.isDead == true) { NGHubDropdownWindow window = EditorWindow.CreateInstance <NGHubDropdownWindow>(); window.Init(this.source, this.hiddenI); r.x = this.position.x + this.position.width - 150F; r.y += this.position.y - 5F; window.ShowAsDropDown(r, new Vector2(150F, 4F + 24F * (this.source.components.Count - this.hiddenI))); } } } EditorGUILayout.BeginHorizontal(GUILayoutOptionPool.Height(this.source.height)); { this.source.HandleDrop(); EventType catchedType = EventType.Used; if (Event.current.type == EventType.Repaint) { this.overflowing = false; } for (int i = this.minI; i < this.source.components.Count; i++) { // Catch event from the cropped component. if (Event.current.type != EventType.Repaint && Event.current.type != EventType.Layout) { if (this.hiddenI == i) { // Simulate context click, because MouseUp is used, therefore ContextClick is not sent. if (Event.current.type == EventType.MouseUp && Event.current.button == 1) { catchedType = EventType.ContextClick; } else { catchedType = Event.current.type; } Event.current.Use(); } } EditorGUILayout.BeginHorizontal(); { this.source.components[i].OnGUI(); } EditorGUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint) { Rect r = GUILayoutUtility.GetLastRect(); if (r.xMax >= this.position.width) { // Hide the miserable trick... r.xMin -= 2F; r.yMin -= 3F; r.yMax += 2F; r.xMax += 2F; EditorGUI.DrawRect(r, NGHubWindow.DockBackgroundColor); this.hiddenI = i; this.overflowing = true; break; } else if (this.hiddenI == i) { --this.hiddenI; } } } if (Event.current.type == EventType.ContextClick || catchedType == EventType.ContextClick) { this.source.OpenContextMenu(); } } GUILayout.FlexibleSpace(); if (this.overflowing == true) { Rect r = this.position; r.y = 5F; r.x = r.width - 20F; r.width = 20F; GUI.Button(r, "", "Dropdown"); } EditorGUILayout.EndHorizontal(); }
public override void OnGUI(Rect r) { this.currentVars = this.perWindowVars.Get(RowUtility.drawingWindow); float yOrigin = r.y; float maxHeight = r.height; r.y += 2F; r.height = Constants.SingleLineHeight + 2F; // Layout is requiring 2 more pixels. GUILayout.BeginArea(r); { GUILayout.BeginHorizontal(GeneralStyles.Toolbar); { if (GUILayout.Button("Clear", GeneralStyles.ToolbarButton) == true) { this.Clear(); } List <NGServerInstance> servers = ConnectionsManager.Servers; lock (ConnectionsManager.Servers) { EditorGUI.BeginDisabledGroup(this.connectingThread != null || servers.Count == 0); { if (servers.Count == 0) { Utility.content.text = "No server"; } else if (servers.Count == 1) { Utility.content.text = "1 server"; } else { Utility.content.text = servers.Count + " servers"; } Rect r2 = GUILayoutUtility.GetRect(Utility.content, GeneralStyles.ToolbarDropDown); if (GUI.Button(r2, Utility.content, GeneralStyles.ToolbarDropDown) == true) { PopupWindow.Show(new Rect(0F, 16F, 0F, 0F), new ServersSelectorWindow(this)); } } EditorGUI.EndDisabledGroup(); } EditorGUI.BeginDisabledGroup(this.connectingThread != null || this.IsClientConnected()); { if (this.tcpClientProviderNames.Length > 1) { EditorGUI.BeginChangeCheck(); this.selectedTcpClientProvider = EditorGUILayout.Popup(this.selectedTcpClientProvider, this.tcpClientProviderNames, GeneralStyles.ToolbarDropDown); if (EditorGUI.EndChangeCheck() == true) { this.console.SaveModules(); } } EditorGUI.BeginChangeCheck(); this.address = EditorGUILayout.TextField(this.address, GUILayoutOptionPool.MinWidth(50F)); if (EditorGUI.EndChangeCheck() == true) { this.console.SaveModules(); } if (string.IsNullOrEmpty(this.address) == true) { Rect r2 = GUILayoutUtility.GetLastRect(); EditorGUI.LabelField(r2, LC.G("RemoteModule_Address"), GeneralStyles.TextFieldPlaceHolder); } string port = this.port.ToString(); if (port == "0") { port = string.Empty; } EditorGUI.BeginChangeCheck(); port = EditorGUILayout.TextField(port, GUILayoutOptionPool.MaxWidth(40F)); if (EditorGUI.EndChangeCheck() == true) { try { if (string.IsNullOrEmpty(port) == false) { this.port = Mathf.Clamp(int.Parse(port), 0, UInt16.MaxValue - 1); } else { this.port = 0; } } catch { this.port = 0; GUI.FocusControl(null); } this.console.SaveModules(); } if ((port == string.Empty || port == "0") && this.port == 0) { Rect r2 = GUILayoutUtility.GetLastRect(); EditorGUI.LabelField(r2, LC.G("RemoteModule_Port"), GeneralStyles.TextFieldPlaceHolder); } } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); if (this.IsClientConnected() == true) { if (GUILayout.Button(LC.G("RemoteModule_Disconnect"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(80F)) == true) { this.CloseClient(); } if (string.IsNullOrEmpty(this.servicesWarning) == false) { Rect r2 = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(16F)); r2.x += 4F; r2.y += 2F; GUI.DrawTexture(r2, UtilityResources.WarningIcon); if (Event.current.type == EventType.MouseDown && r2.Contains(Event.current.mousePosition) == true) { this.showServicesWarning = !this.showServicesWarning; Event.current.Use(); } } } else { if (this.connectingThread == null) { if (GUILayout.Button(LC.G("RemoteModule_Connect"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(80F)) == true) { this.Connect(this.address, this.port); } } else { Utility.content.text = "Connecting"; Utility.content.image = GeneralStyles.StatusWheel.image; GUILayout.Label(Utility.content, GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(90F)); Utility.content.image = null; this.console.Repaint(); if (GUILayout.Button("X", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(16F)) == true) { this.connectingThread.Abort(); this.connectingThread.Join(0); this.connectingThread = null; } } } } GUILayout.EndHorizontal(); } GUILayout.EndArea(); r.y += r.height; r.height = Constants.SingleLineHeight; if (this.showServicesWarning == true && string.IsNullOrEmpty(this.servicesWarning) == false) { r.height = Constants.SingleLineHeight + Constants.SingleLineHeight; EditorGUI.HelpBox(r, this.servicesWarning, MessageType.Warning); Rect r2 = r; r2.xMin = r.xMax - 20F; r2.yMin = r.yMax - 15F; if (GUI.Button(r2, "X") == true) { this.showServicesWarning = false; } r.y += r.height; r.height = Constants.SingleLineHeight; } r = this.DrawStreamTabs(r); if (this.currentVars.workingStream < 0) { return; } if (this.IsClientConnected() == true) { float streamHeight = maxHeight - (r.y - yOrigin) - Constants.SingleLineHeight; float xMin = r.xMin; r.xMin = 0F; r.y += streamHeight; // Draw CLI before rows. r.height = Constants.SingleLineHeight; this.DrawCLI(r); // Shit of a hack to handle input for completion and its drawing. this.parser.PostGUI(r, ref this.command); r.xMin = xMin; r.y -= streamHeight; r.height = streamHeight; this.streams[this.currentVars.workingStream].OnGUI(r); r.y += streamHeight; // Redraw again to display in front. this.parser.PostGUI(r, ref this.command); } else { r.height = maxHeight - (r.y - yOrigin); this.streams[this.currentVars.workingStream].OnGUI(r); } }
private static void OnGUISettings() { if (HQ.Settings == null) { return; } EditorGUILayout.Space(); FullscreenBindingsSettings settings = HQ.Settings.Get <FullscreenBindingsSettings>(); // Rebuild and restore as much as we can the previous bindings. if (settings.bindings == null || settings.bindings.Length != 12) { FullscreenBindingsSettings.Binding[] newBindings = new FullscreenBindingsSettings.Binding[12]; Type type = Utility.GetType("NGToolsEditor.NGFullscreenBindings", "ExternalNGFullscreenBindings"); if (settings.bindings != null) { for (int i = 0; i < settings.bindings.Length && i < newBindings.Length; i++) { newBindings[i] = new FullscreenBindingsSettings.Binding(settings.bindings[i].label, settings.bindings[i].type) { active = settings.bindings[i].active, ctrl = settings.bindings[i].ctrl, shift = settings.bindings[i].shift, alt = settings.bindings[i].alt, }; } for (int i = 0; i < settings.bindings.Length; i++) { FieldInfo field = type.GetField("F" + (i + 1)); if (field != null) { newBindings[i] = new FullscreenBindingsSettings.Binding((string)field.GetRawConstantValue(), string.Empty) { active = type.GetMethod("ToggleFullscreenF" + (i + 1)) != null } } ; } } for (int i = 0; i < newBindings.Length; i++) { if (newBindings[i] == null) { newBindings[i] = new FullscreenBindingsSettings.Binding(string.Empty, string.Empty); } } settings.bindings = newBindings; } using (LabelWidthRestorer.Get(30F)) { for (int i = 0; i < settings.bindings.Length; i++) { FullscreenBindingsSettings.Binding binding = settings.bindings[i]; EditorGUILayout.BeginHorizontal(); { binding.active = EditorGUILayout.Toggle(binding.active, GUILayoutOptionPool.Width(12F)); EditorGUI.BeginDisabledGroup(binding.active == false); { GUILayout.Label("F" + (i + 1), GUILayoutOptionPool.Width(25F)); binding.ctrl = GUILayout.Toggle(binding.ctrl, "Ctrl", "ToolbarButton", GUILayoutOptionPool.Width(35F)); binding.shift = GUILayout.Toggle(binding.shift, "Shift", "ToolbarButton", GUILayoutOptionPool.Width(35F)); binding.alt = GUILayout.Toggle(binding.alt, "Alt", "ToolbarButton", GUILayoutOptionPool.Width(35F)); binding.label = EditorGUILayout.TextField(binding.label); GUILayout.FlexibleSpace(); Type t = NGFullscreenBindingsWindow.GetType(settings.bindings[i].type); if (t != null) { GUILayout.Label(t.Name, GUILayoutOptionPool.ExpandWidthFalse); } if (GUILayout.Button("Pick", GUILayoutOptionPool.Width(50F)) == true) { NGFullscreenBindingsWindow.PickType(i); } } EditorGUI.EndDisabledGroup(); } EditorGUILayout.EndHorizontal(); if (NGFullscreenBindingsWindow.regex.IsMatch(binding.label) == false) { EditorGUILayout.HelpBox("Must contains only alpha numeric chars, space, tab, dash, underscore.", MessageType.Error, true); } if (i == 0 && binding.ctrl == false && binding.shift == false && binding.alt == true) { EditorGUILayout.HelpBox("This binding is already used. You must change it.", MessageType.Error, true); } } } if (EditorApplication.isCompiling == true) { using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton)) { GUILayout.Button("Compiling..."); } } else if (GUILayout.Button("Save") == true) { HQ.InvalidateSettings(); NGFullscreenBindingsWindow.Generate(); } }
public override void OnGUI(Rect r) { string[] types = this.hierarchy.GetComponentTypes(); EditorGUI.BeginDisabledGroup(types == null); EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { EditorGUI.BeginChangeCheck(); this.searchKeywords = EditorGUILayout.TextField(this.searchKeywords, GeneralStyles.ToolbarSearchTextField, GUILayoutOptionPool.ExpandWidthTrue); if (EditorGUI.EndChangeCheck() == true) { this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' '); this.RefreshFilter(types); } if (GUILayout.Button("", GeneralStyles.ToolbarSearchCancelButton) == true) { this.searchKeywords = string.Empty; this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' '); GUI.FocusControl(null); this.RefreshFilter(types); } } EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); if (types == null) { EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUILayout.Label(GeneralStyles.StatusWheel, GUILayoutOptionPool.Width(20F)); GUILayout.Label("Loading types..."); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); this.editorWindow.Repaint(); return; } this.bodyRect = GUILayoutUtility.GetLastRect(); this.bodyRect.y += this.bodyRect.height; float maxY = this.bodyRect.yMax; r.height = Constants.SingleLineHeight; this.bodyRect.height = this.editorWindow.position.height - this.bodyRect.y; this.viewRect = new Rect(0F, 0F, 0F, this.CountTypes(types) * (ClientComponent.MemberSpacing + Constants.SingleLineHeight) - ClientComponent.MemberSpacing); this.scrollPosition = GUI.BeginScrollView(this.bodyRect, this.scrollPosition, this.viewRect); { r.width = this.editorWindow.position.width - (viewRect.height > this.bodyRect.height ? 16F : 0F); r.height = Constants.SingleLineHeight; int i = 0; if (this.viewRect.height > this.bodyRect.height) { i = (int)(this.scrollPosition.y / (ClientComponent.MemberSpacing + r.height)); r.y = i * (ClientComponent.MemberSpacing + r.height); } foreach (string label in this.EachType(types, i--)) { ++i; if (r.y + r.height + ClientComponent.MemberSpacing <= this.scrollPosition.y) { r.y += r.height + ClientComponent.MemberSpacing; continue; } Color restore = GeneralStyles.ToolbarLeftButton.normal.textColor; if (label == this.selectedType) { GeneralStyles.ToolbarLeftButton.normal.textColor = GeneralStyles.HighlightActionButton; } Utility.content.text = label; Utility.content.tooltip = label; if (GUI.Button(r, Utility.content, GeneralStyles.ToolbarLeftButton) == true) { if (this.selectedType == label) { this.hierarchy.AddPacket(new ClientAddComponentPacket(this.gameObjectInstanceID, this.selectedType), this.OnComponentAdded); } this.selectedType = label; } GeneralStyles.ToolbarLeftButton.normal.textColor = restore; r.y += r.height + ClientComponent.MemberSpacing; if (r.y - this.scrollPosition.y > this.bodyRect.height) { break; } } } GUI.EndScrollView(); this.bodyRect.y = maxY; }
protected virtual void OnGUI() { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { if (GUILayout.Button("Open", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(100F)) == true) { this.OpenReplay(); } for (int i = 0; i < this.replays.Count; i++) { EditorGUI.BeginChangeCheck(); NGEditorGUILayout.OutlineToggle(this.replays[i].name, i == this.currentReplay); if (EditorGUI.EndChangeCheck() == true) { if (Event.current.button == 2) { this.replays.RemoveAt(i); return; } else if (Event.current.button == 1) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Delete"), false, (d) => this.replays.RemoveAt((int)d), i); menu.ShowAsContext(); return; } else { if (this.currentReplay >= 0 && this.currentReplay < this.replays.Count) { this.replays[this.currentReplay].Pause(); } this.currentReplay = i; } } } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); if (this.replays.Count == 0) { if (GUILayout.Button("No replay loaded yet, please open one.", GeneralStyles.BigCenterText, GUILayoutOptionPool.ExpandHeightTrue) == true) { this.OpenReplay(); } } if (this.currentReplay >= 0 && this.currentReplay < this.replays.Count) { Replay replay = this.replays[this.currentReplay]; EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { if (replay.canSave == true) { if (GUILayout.Button("Save", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(100F)) == true) { string filepath = EditorUtility.SaveFilePanel("Save Replay", ".", PlayerSettings.productName + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss"), NGReplayWindow.ReplayExtension); if (string.IsNullOrEmpty(filepath) == false) { if (replay.Save(filepath) == false) { InternalNGDebug.LogError("An error occurred. Replay could not been saved at \"" + filepath + "\"."); } else { InternalNGDebug.Log("Replay saved at \"" + filepath + "\"."); } } } } if (GUILayout.Button("<", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(35F)) == true) { replay.Pause(); replay.Set(replay.cursorTime - .1F); } if (GUILayout.Button(">", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(35F)) == true) { replay.Pause(); replay.Set(replay.cursorTime + .1F); } if (replay.playing == false) { if (GUILayout.Button("►", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(75F)) == true) { replay.Play(); } } else { if (GUILayout.Button("▮▮", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(75F)) == true) { replay.Pause(); } } if (GUILayout.Button("■", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(75F)) == true) { replay.Stop(); } GUILayout.FlexibleSpace(); using (LabelWidthRestorer.Get(50F)) { replay.speed = EditorGUILayout.FloatField("Speed", replay.speed, GUILayoutOptionPool.Width(75F)); } EditorGUI.BeginChangeCheck(); Utility.content.text = " ∞ "; Utility.content.tooltip = "Repeat"; GUILayout.Toggle(replay.repeat, Utility.content, GeneralStyles.ToolbarButton); if (EditorGUI.EndChangeCheck() == true) { replay.repeat = !replay.repeat; } for (int i = 0; i < replay.modules.Count; i++) { replay.modules[i].OnGUIOptions(this); } Rect r2 = GUILayoutUtility.GetRect(new GUIContent("Modules"), GeneralStyles.ToolbarDropDown); if (GUI.Button(r2, "Modules", GeneralStyles.ToolbarDropDown) == true) { GenericMenu menu = new GenericMenu(); for (int i = 0; i < replay.modules.Count; i++) { if (replay.modules[i].moduleID == ScreenshotModule.ModuleID) { continue; } menu.AddItem(new GUIContent(replay.modules[i].name), replay.modules[i].active, this.ToggleModule, replay.modules[i]); } menu.DropDown(r2); } if (Conf.DebugMode != Conf.DebugState.None) { EditorGUI.BeginChangeCheck(); GUILayout.Toggle(this.showDBG, "DBG", GeneralStyles.ToolbarButton); if (EditorGUI.EndChangeCheck() == true) { this.showDBG = !this.showDBG; } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginChangeCheck(); float t = EditorGUILayout.Slider(replay.cursorTime, 0F, replay.maxTime); if (EditorGUI.EndChangeCheck() == true) { replay.Pause(); replay.Set(t, true); } GUILayout.Label("/ " + replay.maxTime, GUILayoutOptionPool.ExpandWidthFalse); } EditorGUILayout.EndHorizontal(); Rect r = GUILayoutUtility.GetRect(0F, 0F, GUILayoutOptionPool.ExpandWidthTrue, GUILayoutOptionPool.ExpandHeightTrue); for (int i = 0; i < replay.modules.Count; i++) { if (replay.modules[i].active == true) { replay.modules[i].OnGUIReplay(r); } } if (Conf.DebugMode != Conf.DebugState.None && this.showDBG == true) { EditorGUILayout.LabelField("Time Offset", replay.realTimeOffset.ToString()); for (int i = 0; i < replay.modules.Count; i++) { if (replay.modules[i].active == true) { replay.modules[i].OnGUIDBG(); } } } } }
private void DrawComponent(ComponentContainer container) { Editor e = Editor.CreateEditor(container.component); EditorGUILayout.BeginHorizontal(); { GUILayout.Space(2F); Rect r = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(20F)); GUI.DrawTexture(r, container.gameObjectIcon); NGEditorGUILayout.PingObject(container.component.name, container.component.gameObject, GUILayoutOptionPool.Height(16F)); container.useDefaultEditor = GUILayout.Toggle(container.useDefaultEditor, new GUIContent("No Custom Editor", "Use default editor."), GeneralStyles.ToolbarToggle, GUILayoutOptionPool.ExpandWidthFalse); } EditorGUILayout.EndHorizontal(); GUILayout.Space(4F); EditorGUILayout.BeginHorizontal(); { GUILayout.Space(2F); Rect r = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(20F)); if (container.componentIcons[container.workingComponentIndex] != null) { GUI.DrawTexture(r, container.componentIcons[container.workingComponentIndex]); } GUILayout.Space(5F); r = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(16F)); int enabled = EditorUtility.GetObjectEnabled(container.component); if (enabled != -1) { EditorGUI.BeginChangeCheck(); EditorGUI.Toggle(r, enabled == 1); if (EditorGUI.EndChangeCheck() == true) { EditorUtility.SetObjectEnabled(container.component, enabled != 1); } } EditorGUI.BeginChangeCheck(); int n = EditorGUILayout.Popup(container.workingComponentIndex, container.componentNames); if (EditorGUI.EndChangeCheck() == true) { Component[] components = container.component.gameObject.GetComponents <Component>(); if (n < components.Length) { container.Init(components[n]); } } } EditorGUILayout.EndHorizontal(); // Exception for Transform, its Editor messes the GUI up. if (container.useDefaultEditor == true || container.component is Transform) { e.DrawDefaultInspector(); } else { e.OnInspectorGUI(); } }
private static void DrawInputCommand(InputCommand command) { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(LC.G("Input_" + command.name), GeneralStyles.Title1, GUILayoutOptionPool.ExpandWidthFalse); if (ConsoleSettingsEditor.registeringCommand == command) { if (Event.current.type == EventType.KeyUp) { if (Event.current.keyCode == KeyCode.LeftControl || Event.current.keyCode == KeyCode.RightControl) { command.modifiers ^= InputCommand.Control; } else if (Event.current.keyCode == KeyCode.LeftShift || Event.current.keyCode == KeyCode.RightShift) { command.modifiers ^= InputCommand.Shift; } else if (Event.current.keyCode == KeyCode.LeftAlt || Event.current.keyCode == KeyCode.RightAlt) { command.modifiers ^= InputCommand.Alt; } else { command.keyCode = Event.current.keyCode; } Event.current.Use(); } else if (Event.current.shift == true) { ConsoleSettingsEditor.shiftPressed = true; } else if (ConsoleSettingsEditor.shiftPressed == true) { command.modifiers ^= InputCommand.Shift; ConsoleSettingsEditor.shiftPressed = false; } if (GUILayout.Button(LC.G("Stop"), GUILayoutOptionPool.MaxWidth(80F)) == true) { registeringCommand = null; } GUILayout.Label(LC.G("ConsoleSettings_PressAny")); // Force repaint to handle shift input. //ConsoleSettingsEditor.Repaint(); } else if (GUILayout.Button(LC.G("Edit"), GUILayoutOptionPool.MaxWidth(80F)) == true) { Utility.content.text = LC.G("InputsWizard_PressAnythingToEditCommand"); registeringCommand = command; ConsoleSettingsEditor.shiftPressed = false; } } EditorGUILayout.EndHorizontal(); string description = LC.G("Input_" + command.name + InputCommand.DescriptionLocalizationSuffix); if (string.IsNullOrEmpty(description) == false) { EditorGUILayout.LabelField(description, GeneralStyles.WrapLabel); } EditorGUILayout.BeginHorizontal(); { command.keyCode = (KeyCode)EditorGUILayout.EnumPopup(command.keyCode, GUILayoutOptionPool.Width(130F)); EditorGUI.BeginChangeCheck(); GUILayout.Toggle((command.modifiers & InputCommand.Control) != 0, "Ctrl", ConsoleSettingsEditor.menuButtonStyle, GUILayoutOptionPool.Width(50F)); if (EditorGUI.EndChangeCheck() == true) { command.modifiers ^= InputCommand.Control; } EditorGUI.BeginChangeCheck(); GUILayout.Toggle((command.modifiers & InputCommand.Shift) != 0, "Shift", ConsoleSettingsEditor.menuButtonStyle, GUILayoutOptionPool.Width(50F)); if (EditorGUI.EndChangeCheck() == true) { command.modifiers ^= InputCommand.Shift; } EditorGUI.BeginChangeCheck(); GUILayout.Toggle((command.modifiers & InputCommand.Alt) != 0, "Alt", ConsoleSettingsEditor.menuButtonStyle, GUILayoutOptionPool.Width(50F)); if (EditorGUI.EndChangeCheck() == true) { command.modifiers ^= InputCommand.Alt; } } EditorGUILayout.EndHorizontal(); }
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(); }
protected override void OnGUIHeader() { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { if (GUILayout.Button("☰", "GV Gizmo DropDown") == true) { PopupWindow.Show(new Rect(0F, 16F, 0F, 0F), new OptionPopup(this)); } GUILayout.FlexibleSpace(); bool isConnected = this.Hierarchy.IsClientConnected(); EditorGUI.BeginDisabledGroup(!isConnected); if (this.projectAssets == null && (this.autoLoad == true || GUILayout.Button(LC.G("NGProject_Load"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(40F)) == true)) { if (isConnected == true && this.Hierarchy.BlockRequestChannel(this.GetHashCode()) == true) { this.Hierarchy.Client.AddPacket(new ClientRequestProjectPacket(), this.OnProjectReceived); } } EditorGUI.EndDisabledGroup(); } EditorGUILayout.EndHorizontal(); }
protected virtual void OnGUI() { FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGRenamerWindow.FreeAdContent); float halfWidth = this.position.width * .5F - 25F; this.errorPopup.OnGUILayout(); for (int i = 0; i < this.filters.Count; i++) { EditorGUI.BeginDisabledGroup(NGLicensesManager.Check(i < NGRenamerWindow.MaxRenamerFilters, NGAssemblyInfo.Name + " Pro") == false); this.filters[i].OnHeaderGUI(); if (this.filters[i].open == true) { try { this.filters[i].OnGUI(); } catch (Exception ex) { this.errorPopup.exception = ex; } } EditorGUI.EndDisabledGroup(); } if (this.objects.Count > 0 || this.paths.Count > 0 || Selection.activeObject != null) { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button("Replace All") == true) { this.ReplaceAll(); } } if (this.objects.Count > 0) { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { GUILayout.Label("Assets (" + this.objects.Count + ")", GeneralStyles.Title1); } EditorGUILayout.EndHorizontal(); this.assetsScrollPosition = EditorGUILayout.BeginScrollView(this.assetsScrollPosition, GUILayoutOptionPool.ExpandHeightTrue); { for (int i = 0; i < this.objects.Count; i++) { NGRenamerWindow.drawingIndex = i; EditorGUILayout.BeginHorizontal(); { Texture2D icon = Utility.GetIcon(this.objects[i].GetInstanceID()); Rect r = GUILayoutUtility.GetRect(16F, 16F); GUI.DrawTexture(r, icon); r.width += halfWidth - 32F; if (GUI.Button(r, "", GUI.skin.label) == true) { NGEditorGUILayout.PingObject(this.objects[i]); return; } this.DrawElement(Path.GetFileName(this.objects[i].name), halfWidth - 32F, (s) => this.RenameAsset(this.objects[i], s)); if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton) == true) { this.objects.RemoveAt(i); return; } } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); GUILayout.Space(5F); } for (int i = 0; i < this.paths.Count; i++) { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { Rect r = GUILayoutUtility.GetRect(0F, 24F, GUILayoutOptionPool.ExpandWidthTrue); GUI.Label(r, "Path " + this.paths[i].path + " (" + (this.paths[i].directories.Length + this.paths[i].files.Length) + ")", GeneralStyles.Title1); Utility.content.text = "↻"; Utility.content.tooltip = "Refresh folder's content"; if (GUILayout.Button(Utility.content, GeneralStyles.ToolbarAltButton, GUILayoutOptionPool.Width(20F)) == true) { try { this.paths[i].Update(); } catch (Exception ex) { this.errorPopup.exception = ex; } return; } Utility.content.tooltip = string.Empty; if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton, GUILayoutOptionPool.Width(20F)) == true) { this.paths.RemoveAt(i); return; } } EditorGUILayout.EndHorizontal(); try { this.paths[i].scrollPosition = EditorGUILayout.BeginScrollView(this.paths[i].scrollPosition, GUILayoutOptionPool.ExpandHeightTrue); { for (int j = 0; j < this.paths[i].directories.Length; j++) { NGRenamerWindow.drawingIndex = j; this.DrawElement(Path.GetFileName(this.paths[i].directories[j]), halfWidth, (s) => { try { // To ensure different letter case will work. string tmp = Path.Combine(this.paths[i].path, Path.GetRandomFileName()); Directory.Move(this.paths[i].absolutePathDirectories[j], tmp); Directory.Move(tmp, Path.Combine(this.paths[i].path, s)); this.paths[i].directories[j] = s; } catch (Exception ex) { Debug.LogException(ex); } }); } for (int j = 0; j < this.paths[i].files.Length; j++) { NGRenamerWindow.drawingIndex = j; this.DrawElement(Path.GetFileName(this.paths[i].files[j]), halfWidth, (s) => { try { File.Move(this.paths[i].absolutePathFiles[j], Path.Combine(this.paths[i].path, s)); this.paths[i].files[j] = s; } catch (Exception ex) { Debug.LogException(ex); } }); } } EditorGUILayout.EndScrollView(); } catch (Exception ex) { this.paths.RemoveAt(i); Debug.LogException(ex); } GUILayout.Space(5F); } if (Selection.objects.Length > 0) { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { GUILayout.Label("Selection", GeneralStyles.Title1); } EditorGUILayout.EndHorizontal(); this.selectionScrollPosition = EditorGUILayout.BeginScrollView(this.selectionScrollPosition, GUILayoutOptionPool.ExpandHeightTrue); { for (int i = 0; i < Selection.objects.Length; i++) { NGRenamerWindow.drawingIndex = i; this.DrawElement(Selection.objects[i].name, halfWidth, (s) => this.RenameAsset(Selection.objects[i], s)); } } EditorGUILayout.EndScrollView(); } using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button("Replace All") == true) { this.ReplaceAll(); } } GUILayout.FlexibleSpace(); } else { Rect r = GUILayoutUtility.GetRect(this.position.width, 16F, GUILayoutOptionPool.ExpandHeightTrue); r.x += 2F; r.y += 2F; r.width -= 4F; r.height -= 4F; if (Event.current.type == EventType.Repaint) { Utility.DrawUnfillRect(r, Color.grey); } GUI.Label(r, "Select assets from Hierarchy or Project\n\nDrop any files or folders from\n" + (Application.platform == RuntimePlatform.WindowsEditor ? "Explorer, " : (Application.platform == RuntimePlatform.OSXEditor ? "Finder, " : "")) + "Hierarchy or Project", GeneralStyles.CenterText); } if (Event.current.type == EventType.DragUpdated) { if (DragAndDrop.objectReferences.Length > 0 || DragAndDrop.paths.Length > 0) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; } else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } } else if (Event.current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); try { if (DragAndDrop.objectReferences.Length > 0) { for (int i = 0; i < DragAndDrop.objectReferences.Length; i++) { Object obj = DragAndDrop.objectReferences[i]; if (typeof(Behaviour).IsAssignableFrom(obj.GetType()) == true) { obj = (obj as Behaviour).gameObject; } if (this.objects.Contains(obj) == false) { this.objects.Add(obj); } } } else if (DragAndDrop.paths.Length > 0) { for (int i = 0; i < DragAndDrop.paths.Length; i++) { string path = DragAndDrop.paths[i]; if (Directory.Exists(path) == false) { path = new DirectoryInfo(path).Parent.FullName; } if (string.IsNullOrEmpty(path) == false && this.paths.Exists((p) => p.path == path) == false) { this.paths.Add(new PathFiles(path)); } } } } catch (Exception ex) { this.errorPopup.exception = ex; } Event.current.Use(); } else if (Event.current.type == EventType.Repaint && DragAndDrop.visualMode == DragAndDropVisualMode.Move) { Utility.DropZone(new Rect(0F, 0F, this.position.width, this.position.height), "Drop folder or asset to rename"); } FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro"); }
protected virtual void OnGUI() { EditorGUI.BeginChangeCheck(); this.input = EditorGUILayout.TextField("Type", this.input); if (EditorGUI.EndChangeCheck() == true && this.input.Length > 2) { Utility.RegisterIntervalCallback(this.RefreshMatchingTypes, 100, 1); } Type t = Type.GetType(this.input); if (t != null) { if (GUILayout.Button("Analyze " + t.FullName)) { this.membersEmbedded.Clear(); this.type = t; this.fields = t.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); this.properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); this.methods = t.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); for (int i = 0; i < this.fields.Length; i++) { if (this.SkipMember(this.fields[i]) == false) { this.membersEmbedded.Add(this.fields[i]); } } for (int i = 0; i < this.properties.Length; i++) { if (this.SkipMember(this.properties[i]) == false) { this.membersEmbedded.Add(this.properties[i]); } } for (int i = 0; i < this.methods.Length; i++) { if (this.methods[i].Name == "Finalize" || this.methods[i].Name == "GetHashCode" || this.methods[i].Name == "GetType" || this.methods[i].Name == "MemberwiseClone" || this.methods[i].Name == "ToString") { continue; } if (this.SkipMember(this.methods[i]) == false) { this.membersEmbedded.Add(this.methods[i]); } } } } this.scrollPositionAQN = EditorGUILayout.BeginScrollView(this.scrollPositionAQN, GUILayoutOptionPool.Height(Mathf.Min(this.matchingTypes.Count * 18F, 200F))); { for (int i = 0; i < this.matchingTypes.Count; i++) { if (GUILayout.Button(this.matchingTypes[i].FullName) == true) { this.input = this.matchingTypes[i].AssemblyQualifiedName; } } } EditorGUILayout.EndScrollView(); this.scrollPositionMembers = EditorGUILayout.BeginScrollView(this.scrollPositionMembers); { if (this.type != null) { if (string.IsNullOrEmpty(this.result) == false) { this.outputFilePath = NGEditorGUILayout.SaveFileField("File", this.outputFilePath); if (GUILayout.Button("Write to file") == true) { File.WriteAllText(this.outputFilePath, this.result); } if (GUILayout.Button("Copy to clipboard") == true) { EditorGUIUtility.systemCopyBuffer = this.result; } if (this.result.Length < short.MaxValue / 2) { EditorGUILayout.TextArea(this.result, GUILayout.MaxHeight(150F)); } else { EditorGUILayout.HelpBox("Result is too big to display.", MessageType.Warning); } } if (GUILayout.Button("Generate") == true) { this.Generate(); } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Fields (" + this.fields.Length + ")"); if (GUILayout.Button("Toggle") == true) { this.ToggleMembers(this.fields); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); ++EditorGUI.indentLevel; this.DrawMembers(this.fields); --EditorGUI.indentLevel; EditorGUILayout.BeginHorizontal(); GUILayout.Label("Properties (" + this.properties.Length + ")"); if (GUILayout.Button("Toggle") == true) { this.ToggleMembers(this.properties); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); ++EditorGUI.indentLevel; this.DrawMembers(this.properties); --EditorGUI.indentLevel; EditorGUILayout.BeginHorizontal(); GUILayout.Label("Methods (" + this.methods.Length + ")"); if (GUILayout.Button("Toggle") == true) { this.ToggleMembers(this.methods); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); ++EditorGUI.indentLevel; this.DrawMembers(this.methods); --EditorGUI.indentLevel; } } EditorGUILayout.EndScrollView(); }
protected override void OnGUIHeader() { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { using (LabelWidthRestorer.Get(70F)) { Utility.content.text = "Filter By"; Rect r = GUILayoutUtility.GetRect(Utility.content, GUI.skin.label, GUILayoutOptionPool.Width(80F)); r.y -= 2F; if (GUI.Button(r, Utility.content.text) == true) { this.filterByPacketId = 0; if (this.Hierarchy.IsClientConnected() == true) { this.pickingFilter = !this.pickingFilter; } else { this.pickingFilter = false; } } if (this.pickingFilter == true) { Utility.content.text = "Click on a packet"; r = GUILayoutUtility.GetRect(Utility.content, GUI.skin.label); r.width += 20F; Utility.DrawRectDotted(r, this.position, Color.grey, 0.02F, 0F); r.x += 10F; GUI.Label(r, Utility.content.text); } else if (this.filterByPacketId != 0) { Utility.content.text = PacketId.GetPacketName(this.filterByPacketId); r = GUILayoutUtility.GetRect(Utility.content, GUI.skin.label); GUI.Label(r, Utility.content.text); if (r.Contains(Event.current.mousePosition) == true && Event.current.type == EventType.MouseDown) { this.filterByPacketId = 0; this.Repaint(); Event.current.Use(); } } } GUILayout.FlexibleSpace(); this.hidePingPackets = GUILayout.Toggle(this.hidePingPackets, "Hide Ping", GeneralStyles.ToolbarToggle); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); }
public void Draw(NGMissingScriptRecoveryWindow window, bool force = false) { if (this.cachedFields == null) { StringBuilder buffer = Utility.GetBuffer(); for (int i = 0; i < this.fields.Count; i++) { buffer.AppendLine(this.fields[i]); } if (buffer.Length > 0) { buffer.Length -= Environment.NewLine.Length; } this.cachedFields = Utility.ReturnBuffer(buffer); } EditorGUI.BeginDisabledGroup(this.fields.Count <= 0); { Utility.content.text = this.name; Utility.content.image = Utility.GetIcon(this.asset ? this.asset.GetInstanceID() : 0); this.open = EditorGUILayout.Foldout(this.open, Utility.content) && this.fields.Count > 0 || force; Utility.content.image = null; } EditorGUI.EndDisabledGroup(); if (this.fields.Count == 0 && this.asset == null) { EditorGUILayout.HelpBox("Component seems to have absolutely no fields. Recovery can not proceed.", MessageType.Warning); } if (this.open == false) { return; } ++EditorGUI.indentLevel; this.fieldsOpen = EditorGUILayout.Foldout(this.fieldsOpen, "Fields found (" + this.fields.Count + ")"); if (this.fieldsOpen == true) { ++EditorGUI.indentLevel; Utility.content.text = this.cachedFields; float h = EditorStyles.label.CalcHeight(Utility.content, window.position.width - 60F); //float h = this.fields.Count * 15F; float totalH = h; if (h >= NGMissingScriptRecoveryWindow.MaxFieldsHeight) { h = NGMissingScriptRecoveryWindow.MaxFieldsHeight; } //Utility.content.text = this.cachedFields; //Rect viewRect = new Rect(); //Rect body = new Rect(4F, GUILayoutUtility.GetLastRect().yMax, window.position.width, 0F); //Rect r2 = GUILayoutUtility.GetRect(0F, h); //body.height = r2.height; //viewRect.height = EditorStyles.label.CalcSize(Utility.content).y; //EditorGUI.DrawRect(body, Color.blue); //this.scrollPositionFields = GUI.BeginScrollView(body, this.scrollPositionFields, viewRect); //{ // Rect selectableRect = body; // selectableRect.x = 0F; // selectableRect.y = 0F; // selectableRect.width = body.width - (viewRect.height > body.height ? 16F : 0F); // selectableRect.height = viewRect.height > body.height ? EditorStyles.label.CalcHeight(Utility.content, selectableRect.width) : viewRect.height; // EditorGUI.SelectableLabel(selectableRect, this.cachedFields, EditorStyles.label); //} //GUI.EndScrollView(); // TODO Fix bottom margin/padding? EditorGUI.HelpBox(new Rect(30F, GUILayoutUtility.GetLastRect().yMax, window.position.width - 60F, h + 10F), string.Empty, MessageType.None); //if (useScrollbar == true) this.scrollPositionFields = EditorGUILayout.BeginScrollView(this.scrollPositionFields, GUILayoutOptionPool.Height(h + 5F), GUILayoutOptionPool.Width(window.position.width - 30F)); //else //EditorGUI.HelpBox(new Rect(4F, GUILayoutUtility.GetLastRect().yMax, window.position.width, h), string.Empty, MessageType.None); { EditorGUILayout.SelectableLabel(this.cachedFields, EditorStyles.label, GUILayoutOptionPool.Height(totalH)); //for (int j = 0; j < this.fields.Count; j++) // EditorGUILayout.LabelField(this.fields[j]); } //if (useScrollbar == true) EditorGUILayout.EndScrollView(); --EditorGUI.indentLevel; } CachedLineFix lineFix = window.FindCachedComponentFixes(this.line); if (lineFix != null) { if (GUILayout.Button("Recover From Cache (" + lineFix.type + ")") == true) { this.FixLine(window, this.componentID, lineFix.type); window.Diagnose(window.Target); } } EditorGUILayout.LabelField("Potential types:"); ++EditorGUI.indentLevel; if (this.potentialTypes.Count == 0) { EditorGUILayout.LabelField("No type available."); } else { for (int l = 0; l < this.potentialTypes.Count; l++) { EditorGUILayout.BeginHorizontal(); { GUILayout.Space(30F); if (GUILayout.Button(this.potentialTypes[l].type.FullName, GUILayoutOptionPool.ExpandWidthFalse) == true) { this.FixMissingComponent(window, this.componentID, this.potentialTypes[l].type); window.Diagnose(window.Target); return; } if (this.potentialTypes[l].matchingFields == this.fields.Count && this.potentialTypes[l].fields.Length == this.fields.Count) { GUILayout.Label("(Perfect match)", GUILayoutOptionPool.ExpandWidthFalse); } else { int extraFields = this.potentialTypes[l].fields.Length == this.potentialTypes[l].matchingFields ? this.potentialTypes[l].matchingFields - this.fields.Count : this.potentialTypes[l].fields.Length - this.potentialTypes[l].matchingFields; GUILayout.Label("(Fields: " + this.potentialTypes[l].matchingFields + " matching" + (extraFields > 0 ? ", +" + extraFields + " extra" : (extraFields < 0 ? ", " + extraFields + " missing" : string.Empty)) + ")", GUILayoutOptionPool.ExpandWidthFalse); } if (Event.current.type == EventType.MouseMove) { Rect r = GUILayoutUtility.GetLastRect(); r.xMin = 0F; if (r.Contains(Event.current.mousePosition) == true) { if (this.hoverPopup != null) { if (this.hoverPopup.potentialType.type != this.potentialTypes[l].type) { if (this.hoverPopup.editorWindow != null) { this.hoverPopup.editorWindow.Close(); } this.hoverPopup = new HighlightMatchesPopup(this, this.potentialTypes[l]); r.x = 30F; r.y += 5F; PopupWindow.Show(r, this.hoverPopup); } } else { this.hoverPopup = new HighlightMatchesPopup(this, this.potentialTypes[l]); r.x = 30F; r.y += 5F; PopupWindow.Show(r, this.hoverPopup); } } else { if (this.hoverPopup != null && this.hoverPopup.potentialType.type == this.potentialTypes[l].type) { if (this.hoverPopup.editorWindow != null) { this.hoverPopup.editorWindow.Close(); } this.hoverPopup = null; } } } } EditorGUILayout.EndHorizontal(); } } --EditorGUI.indentLevel; --EditorGUI.indentLevel; }
protected virtual void OnGUI() { Rect r = this.position; r.x = 0F; r.y = 0F; if (this.prefManagers.Length > 0) { r.height = Constants.SingleLineHeight; GUILayout.BeginArea(r); { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { EditorGUI.BeginChangeCheck(); this.currentManager = EditorGUILayout.Popup(this.currentManager, this.prefManagerNames, GeneralStyles.ToolbarDropDown); if (EditorGUI.EndChangeCheck() == true) { this.LoadCurrentPreferences(); return; } if (GUILayout.Button(this.showAdd == true ? "˄" : "˅", GeneralStyles.ToolbarDropDown, GUILayoutOptionPool.Width(24F)) == true) { this.showAdd = !this.showAdd; return; } EditorGUI.BeginChangeCheck(); this.searchKeywords = EditorGUILayout.TextField(this.searchKeywords, GeneralStyles.ToolbarSearchTextField); if (EditorGUI.EndChangeCheck() == true) { this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' '); this.UpdateFilteredIndexes(); return; } if (GUILayout.Button("", GeneralStyles.ToolbarSearchCancelButton) == true) { this.searchKeywords = string.Empty; this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' '); GUI.FocusControl(null); this.UpdateFilteredIndexes(); return; } if (GUILayout.Button(LC.G("NGPrefs_Refresh"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.MaxWidth(100F))) { this.LoadCurrentPreferences(); GUI.FocusControl(null); return; } if (string.IsNullOrEmpty(this.searchKeywords) == true) { if (GUILayout.Button(LC.G("NGPrefs_ClearAll"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.MaxWidth(100F)) && ((Event.current.modifiers & Constants.ByPassPromptModifier) != 0 || EditorUtility.DisplayDialog(LC.G("NGPrefs_ClearAll"), LC.G("NGPrefs_ClearAllConfirm"), LC.G("Yes"), LC.G("No")) == true)) { try { this.prefManagers[this.currentManager].DeleteAll(); } catch (Exception ex) { this.errorPopup.exception = ex; } return; } } else { if (GUILayout.Button(LC.G("NGPrefs_ClearList"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.MaxWidth(100F)) && ((Event.current.modifiers & Constants.ByPassPromptModifier) != 0 || EditorUtility.DisplayDialog(LC.G("NGPrefs_ClearList"), LC.G("NGPrefs_ClearListConfirm"), LC.G("Yes"), LC.G("No")) == true)) { try { for (int k = 0; k < this.filteredIndexes.Count; k++) { int i = this.filteredIndexes[k]; this.prefManagers[this.currentManager].DeleteKey(this.prefManagers[this.currentManager].keys[i]); } for (int k = 0; k < this.filteredIndexes.Count; k++) { int i = this.filteredIndexes[k]; this.prefManagers[this.currentManager].DeleteIndex(i - k); } this.filteredIndexes.Clear(); } catch (Exception ex) { this.errorPopup.exception = ex; } return; } } } EditorGUILayout.EndHorizontal(); } GUILayout.EndArea(); if (this.showAdd == true) { r.y += r.height; GUILayout.BeginArea(r); { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { using (LabelWidthRestorer.Get(60F)) { this.prefType = (PrefType)EditorGUILayout.EnumPopup(LC.G("NGPrefs_Type"), this.prefType, GeneralStyles.ToolbarDropDown, GUILayoutOptionPool.ExpandWidthFalse); this.newKey = EditorGUILayout.TextField(LC.G("NGPrefs_Key"), this.newKey, GeneralStyles.ToolbarTextField, GUILayoutOptionPool.ExpandWidthTrue); switch (this.prefType) { case PrefType.Int: this.newValueInt = EditorGUILayout.IntField(LC.G("NGPrefs_Value"), this.newValueInt, GeneralStyles.ToolbarTextField, GUILayoutOptionPool.ExpandWidthTrue); break; case PrefType.Float: this.newValueFloat = EditorGUILayout.FloatField(LC.G("NGPrefs_Value"), this.newValueFloat, GeneralStyles.ToolbarTextField, GUILayoutOptionPool.ExpandWidthTrue); break; case PrefType.String: this.newValueString = EditorGUILayout.TextField(LC.G("NGPrefs_Value"), this.newValueString, GeneralStyles.ToolbarTextField, GUILayoutOptionPool.ExpandWidthTrue); break; } EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(this.newKey)); { if (GUILayout.Button(LC.G("NGPrefs_Add"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.MaxWidth(100F))) { switch (this.prefType) { case PrefType.Int: this.prefManagers[this.currentManager].SetInt(this.newKey, this.newValueInt); break; case PrefType.Float: this.prefManagers[this.currentManager].SetFloat(this.newKey, this.newValueFloat); break; case PrefType.String: this.prefManagers[this.currentManager].SetString(this.newKey, this.newValueString); break; } this.LoadCurrentPreferences(); return; } } EditorGUI.EndDisabledGroup(); } } EditorGUILayout.EndHorizontal(); } GUILayout.EndArea(); } } r.y += r.height; if (this.errorPopup.exception != null) { r.height = this.errorPopup.boxHeight; this.errorPopup.OnGUIRect(r); r.y += r.height; r.height = Constants.SingleLineHeight; } if (this.OSXPListMissing == true) { r.height = 32F; EditorGUI.HelpBox(r, "NG Tools seems to be initializing for the first time. " + NGPrefsWindow.Title + " can not work on first initialization, because it needs the preferences file generated by Unity, which does not exist at this moment.", MessageType.Warning); r.y += r.height; EditorGUI.HelpBox(r, "To force Unity to generate it, I suggest you to use EditorPrefs or PlayerPrefs from a custom script then restart Unity.", MessageType.Info); r.y += r.height; r.height = Constants.SingleLineHeight; } if (this.currentManager < 0) { return; } r.y += 1F; this.labelWidth = Mathf.Clamp(this.labelWidth, NGPrefsWindow.MinLabelWidth, this.position.width - NGPrefsWindow.MinValueWidth); r.width = this.labelWidth; EditorGUI.LabelField(r, LC.G("NGPrefs_Key"), GeneralStyles.CenterText); r.x += r.width + 20F; r.width = 2F; EditorGUI.DrawRect(r, Color.grey); r.x -= 1F; r.width += 2F; EditorGUIUtility.AddCursorRect(r, MouseCursor.ResizeHorizontal); if (this.draggingSplitterBar == true && Event.current.type == EventType.MouseDrag) { if (Mathf.Abs(r.y - Event.current.mousePosition.y) > NGPrefsWindow.AutoRestoreLabelWidthThreshold) { this.labelWidth = this.originLabelWidth; } else { this.labelWidth = Mathf.Clamp(this.originLabelWidth - this.originPositionX + Event.current.mousePosition.x, NGPrefsWindow.MinLabelWidth, this.position.width - NGPrefsWindow.MinValueWidth); } Event.current.Use(); } else if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true) { this.originPositionX = Event.current.mousePosition.x; this.originLabelWidth = this.labelWidth; 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 (r.Contains(Event.current.mousePosition) == true && (Event.current.button == 1 || (this.lastClick + Constants.DoubleClickTime > EditorApplication.timeSinceStartup && Mathf.Abs(this.originPositionX - Event.current.mousePosition.x) < 5F))) { this.labelWidth = EditorGUIUtility.labelWidth; } this.lastClick = EditorApplication.timeSinceStartup; this.draggingSplitterBar = false; Event.current.Use(); } r.width = this.position.width - r.x; EditorGUI.LabelField(r, LC.G("NGPrefs_Value"), GeneralStyles.CenterText); r.x = 0F; r.y += r.height + 1F; r.width = this.position.width; r.height = 1F; EditorGUI.DrawRect(r, NGPrefsWindow.ColumnHeaderBackgroundColor); r.y += 3F; r.height = this.position.height - r.y; this.bodyRect = r; Rect viewRect = new Rect(); viewRect.height = this.filteredIndexes.Count * Constants.SingleLineHeight; viewRect.width = r.width - (viewRect.height >= this.bodyRect.height ? 15F : 0F); using (LabelWidthRestorer.Get(this.labelWidth)) { this.scrollPosition = GUI.BeginScrollView(r, this.scrollPosition, viewRect); { r.y = 0F; r.height = Constants.SingleLineHeight; r.width -= viewRect.height >= this.bodyRect.height ? 15F : 0F; this.OnGUIPreferences(r); } GUI.EndScrollView(); } }
protected virtual void OnGUI() { if (this.maxSize == this.minSize) { if (GUI.Button(new Rect(this.position.width - 20F, 0F, 20F, 20F), "X") == true) { this.Close(); } } FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGScenesWindow.FreeAdContent); GUILayout.BeginHorizontal(); { GUILayout.Space(5F); GUILayout.BeginVertical(GUILayoutOptionPool.MinWidth(200F)); { GUILayout.Label("Recent Scenes:", GeneralStyles.Title1); this.recentListDrawer.OnGUI(GUILayoutUtility.GetRect(0F, 100F)); GUILayout.Label("All Scenes:", GeneralStyles.Title1); this.allListDrawer.OnGUI(GUILayoutUtility.GetRect(0F, 0F, GUILayoutOptionPool.ExpandHeightTrue)); } GUILayout.EndVertical(); GUILayout.Space(2F); GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.Label("Build Scenes:", GeneralStyles.Title1); if (HQ.Settings != null) { Utility.content.text = "Load profile"; Rect r = GUILayoutUtility.GetRect(Utility.content, "ToolbarDropDown"); if (GUI.Button(r, Utility.content, "ToolbarDropDown") == true) { GenericMenu menu = new GenericMenu(); ScenesSettings settings = HQ.Settings.Get <ScenesSettings>(); if (settings.profiles.Count > 0) { for (int i = 0; i < settings.profiles.Count; i++) { menu.AddItem(new GUIContent((i + 1) + " - " + settings.profiles[i].name + " (" + settings.profiles[i].scenes.Count + ")"), false, this.LoadProfile, i); } } else { menu.AddItem(new GUIContent("No profile available."), false, null); } menu.DropDown(r); } Utility.content.text = "☰"; r = GUILayoutUtility.GetRect(Utility.content, "GV Gizmo DropDown", GUILayoutOptionPool.ExpandWidthFalse); if (GUI.Button(r, Utility.content, "GV Gizmo DropDown") == true) { PopupWindow.Show(r, new OptionPopup(this)); } if (this.maxSize == this.minSize) { GUILayout.Space(20F); } } } GUILayout.EndHorizontal(); this.enabledScenesCounter = 0; this.buildListDrawer.array = EditorBuildSettings.scenes; this.buildListDrawer.OnGUI(GUILayoutUtility.GetRect(0F, 0F, GUILayoutOptionPool.ExpandHeightTrue)); GUILayout.Space(5F); } GUILayout.EndVertical(); GUILayout.Space(5F); } GUILayout.EndHorizontal(); if (Event.current.type == EventType.MouseDown) { if (this.lastClick + Constants.DoubleClickTime > EditorApplication.timeSinceStartup) { this.Close(); } this.lastClick = EditorApplication.timeSinceStartup; Event.current.Use(); } FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro"); }
public override void OnGUI() { if (this.unwrapLabel == null) { this.unwrapLabel = new GUIStyle(GUI.skin.label); this.unwrapLabel.wordWrap = false; this.buttonLeft = new GUIStyle("ButtonLeft"); this.buttonRight = new GUIStyle("ButtonRight"); this.buttonMid = new GUIStyle("ButtonMid"); } for (int i = NGNavSelectionWindow.historic.Count - 1; i >= 0 && i >= NGNavSelectionWindow.historic.Count - this.maxElements; i--) { AssetsSelection selection = NGNavSelectionWindow.historic[i]; Texture2D image = null; string label = string.Empty; if (selection.refs.Count > 0) { if (selection.refs[0].@object == null) { if (selection.refs[0].hierarchy.Count > 0) { label = (string.IsNullOrEmpty(selection.refs[0].resolverAssemblyQualifiedName) == false ? "(R)" : "") + selection.refs[0].hierarchy[selection.refs[0].hierarchy.Count - 1]; } else { label = "Unknown"; } } else { label = selection.refs[0][email protected]; } } if (selection.refs.Count > 1) { label = "(" + selection.refs.Count + ") " + label; } image = Utility.GetIcon(selection.refs[0][email protected]()); float width = this.maxWidth; GUIStyle style; if (i == NGNavSelectionWindow.historic.Count - 1) { style = this.buttonLeft; } else if (i == 0 || i == NGNavSelectionWindow.historic.Count - this.maxElements) { style = this.buttonRight; } else { style = this.buttonMid; } Rect r = GUILayoutUtility.GetRect(GUIContent.none, style, GUILayoutOptionPool.Height(this.hub.height), GUILayoutOptionPool.Width(width)); if (Event.current.type == EventType.MouseDrag && (this.dragOriginPosition - Event.current.mousePosition).sqrMagnitude >= Constants.MinStartDragDistance && i.Equals(DragAndDrop.GetGenericData(Utility.DragObjectDataName)) == true) { DragAndDrop.StartDrag("Drag Object"); Event.current.Use(); } else if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true) { this.dragOriginPosition = Event.current.mousePosition; if (Event.current.button == 0) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[] { selection.refs[0].@object }; DragAndDrop.SetGenericData(Utility.DragObjectDataName, i); DragAndDrop.SetGenericData(NGHubWindow.DragFromNGHub, true); } } if (GUI.Button(r, string.Empty, style) == true) { if (Event.current.button == 1 || this.lastClick + Constants.DoubleClickTime > EditorApplication.timeSinceStartup) { selection.Select(); NGNavSelectionWindow.lastFocusedHistoric = i; Utility.RepaintEditorWindow(typeof(NGNavSelectionWindow)); } else if (Event.current.button == 0) { EditorGUIUtility.PingObject(selection.refs[0].@object); } this.lastClick = EditorApplication.timeSinceStartup; } if (image != null) { width = r.width; r.xMax = r.xMin + 16F; r.x += 2F; GUI.DrawTexture(r, image, ScaleMode.ScaleToFit); r.xMin += r.width; r.width = width - r.width - 20F; } r.y += 3F; Utility.content.text = label; Utility.content.tooltip = label; GUI.Label(r, Utility.content, this.unwrapLabel); } Utility.content.tooltip = null; }