public override void OnGUI(Rect r) { ScenesSettings settings = HQ.Settings.Get <ScenesSettings>(); for (int i = 0; i < settings.profiles.Count; i++) { GUILayout.BeginHorizontal(); { using (BgColorContentRestorer.Get(i == this.animOn && this.anim.af.isAnimating, Color.Lerp(GUI.contentColor, OptionPopup.HighlightColor, this.anim.Value))) { if (GUILayout.Button("Save In", GeneralStyles.ToolbarButton, GUILayoutOptionPool.ExpandWidthFalse) == true) { this.animOn = i; this.anim.Start(); settings.profiles[i].Save(); HQ.InvalidateSettings(); this.window.Repaint(); } EditorGUI.BeginChangeCheck(); string name = EditorGUILayout.TextField(settings.profiles[i].name); if (EditorGUI.EndChangeCheck() == true) { settings.profiles[i].name = name; HQ.InvalidateSettings(); } } if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton, GUILayoutOptionPool.ExpandWidthFalse) == true) { settings.profiles.RemoveAt(i); HQ.InvalidateSettings(); return; } } GUILayout.EndHorizontal(); } if (GUILayout.Button("Add") == true && this.window.CheckMaxBuildSceneProfiles(settings.profiles.Count) == true) { Profile p = new Profile() { name = "New" }; p.Save(); settings.profiles.Add(p); r.height = (settings.profiles.Count + 1) * 19F; this.editorWindow.position = r; } }
public void OnGUI(Rect r, int i, float minY, float maxY, Project master = null) { if (this.root == null || (master == null && this.watcher == null)) { return; } GUI.Box(r, GUIContent.none, GeneralStyles.Toolbar); float w = r.width; r.height = 16F; Utility.content.text = master == null ? "[Master]" : "[Slave " + i + "]"; r.width = GUI.skin.label.CalcSize(Utility.content).x; GUI.Label(r, Utility.content); r.x += r.width; r.width = w - r.width; if (master != null) { r.width -= 75F; } NGEditorGUILayout.ElasticLabel(r, this.root.path, '/'); using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton)) { EditorGUI.BeginDisabledGroup(this.root.CanDisplay == false); { if (master != null) { r.x += r.width; r.width = 75F; if (GUI.Button(r, "Sync", GeneralStyles.ToolbarButton) == true) { this.SyncAll(master); } } } EditorGUI.EndDisabledGroup(); } r.x = 0F; r.y += r.height; r.width = w; if (master != null) { this.root.OnGUI(r, minY, maxY, master.root); } else { this.root.OnGUI(r, minY, maxY, null); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (this.shaders == null) { this.shaders = property.FindPropertyRelative("shaders"); this.properties = property.FindPropertyRelative("properties"); } if (this.shaders.arraySize == 0) { position.width -= 75F; EditorGUI.LabelField(position, "Shaders", "No shader referenced."); position.x += position.width; position.width = 75F; } else { position.width -= 150F; EditorGUI.LabelField(position, "Shaders", this.shaders.arraySize + " (" + this.properties.arraySize + "B)"); position.x += position.width; position.width = 75F; using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUI.Button(position, "Clear") == true) { this.shaders.ClearArray(); this.properties.ClearArray(); this.shaders.serializedObject.ApplyModifiedProperties(); } } position.x += position.width; } using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUI.Button(position, "Scan") == true && ((Event.current.modifiers & Constants.ByPassPromptModifier) != 0 || EditorUtility.DisplayDialog("Confirm", "Referencing all shaders might take a while. It will scan all the files in the Assets folder.", LC.G("Yes"), LC.G("No")) == true)) { try { this.ReferenceAll(); } catch (Exception ex) { InternalNGDebug.LogException("The scan failed seeking for all shaders.", ex); } } } }
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(); }
protected virtual void OnGUI() { if (this.existingList == null) { this.Init(); } Rect r = this.position; Rect viewRect = default(Rect); r.x = 0F; r.y = 0F; float yMax = r.yMax; Utility.content.text = "NG Remote Project Assets (" + this.origin.assets.Length + ")"; r.height = GeneralStyles.Title1.CalcSize(Utility.content).y; GUI.Label(r, Utility.content, GeneralStyles.Title1); r.y += r.height; using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { r.height = Constants.SingleLineHeight; if (GUI.Button(r, "Reference Resources") == true) { this.ReferenceAssets(); } r.y += r.height + 3F; } viewRect.height = this.root.GetHeight(); r.yMax = yMax; this.scrollPosition = GUI.BeginScrollView(r, this.scrollPosition, viewRect); { float bodyHeight = r.height; r.y = 0F; r.height = this.root.GetHeight(); this.root.Draw(r, this.scrollPosition.y, bodyHeight + this.scrollPosition.y); } GUI.EndScrollView(); }
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 void DrawRow(RowsDrawer rowsDrawer, Rect r, int i, bool?collapse) { LogSettings settings = HQ.Settings.Get <LogSettings>(); float originWidth = RowUtility.drawingWindow.position.width - rowsDrawer.verticalScrollbarWidth; // Draw highlight. r.x = 0F; r.width = originWidth; r.height = settings.height; this.DrawBackground(rowsDrawer, r, i); r.x += 2F; r.width = 16F; bool lastValue = this.isOpened; Color foldoutColor = this.hasError == true ? ConsoleConstants.ErrorFoldoutColor : ConsoleConstants.WarningFoldoutColor; using (BgColorContentRestorer.Get(foldoutColor)) { this.isOpened = EditorGUI.Foldout(r, this.isOpened, ""); } if (lastValue != this.isOpened) { GUI.FocusControl(null); rowsDrawer.InvalidateViewHeight(); } r.x -= 2F; r.width = 3F; EditorGUI.DrawRect(r, foldoutColor); r.width = 16F; r.x += r.width; r.width = originWidth - r.width; this.HandleDefaultSelection(rowsDrawer, r, i); // Toggle on middle-click. if (r.Contains(Event.current.mousePosition) == true && Event.current.type == EventType.MouseDown && Event.current.button == 2) { this.isOpened = !this.isOpened; rowsDrawer.InvalidateViewHeight(); Event.current.Use(); } else if (r.Contains(Event.current.mousePosition) == true && Event.current.type == EventType.MouseUp && Event.current.button == 0) { if (string.IsNullOrEmpty(this.file) == false && RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup) { bool focus = false; if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { focus = true; } if (this.lastGoToFile < this.fileLines.Count) { RowUtility.GoToFileLine(this.file, this.fileLines[this.lastGoToFile].line, focus); ++this.lastGoToFile; if (this.lastGoToFile >= this.fileLines.Count) { this.lastGoToFile = 0; } } else { this.lastGoToFile = 0; } } RowUtility.LastClickTime = EditorApplication.timeSinceStartup; } GUI.Label(r, this.error + " (" + this.fileLines.Count + ")", settings.Style); r.y += settings.height; if (this.isOpened == true) { for (int j = 0; j < this.fileLines.Count; j++) { r.x = 0F; r.width = originWidth; if (Event.current.type == EventType.Repaint && this.selectedSubRow == j && rowsDrawer.currentVars.CountSelection > 0 && rowsDrawer.currentVars.GetSelection(0) == i) { EditorGUI.DrawRect(r, CompileRow.SubRowHighlightColor); } // Handle mouse inputs per log. if (r.Contains(Event.current.mousePosition) == true) { // Toggle on middle click. if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (string.IsNullOrEmpty(this.file) == false && RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup) { bool focus = false; if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { focus = true; } RowUtility.GoToFileLine(this.fileLines[j].file, this.fileLines[j].line, focus); } else { rowsDrawer.currentVars.ClearSelection(); rowsDrawer.currentVars.AddSelection(i); this.selectedSubRow = j; this.log.condition = this.fileLines[j].message; } RowUtility.LastClickTime = EditorApplication.timeSinceStartup; Event.current.Use(); } } // Handle inputs. if (this.fileLines[j].line > 0) { Utility.content.text = this.fileLines[j].line.ToString(); r.width = settings.Style.CalcSize(Utility.content).x; GUI.Label(r, Utility.Color(Utility.content.text, HQ.Settings.Get <StackTraceSettings>().lineColor), settings.Style); r.x += r.width; } r.width = originWidth - r.x; GUI.Label(r, this.fileLines[j].message, settings.Style); r.y += settings.height; } } }
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 (HQ.Settings == null) { GUILayout.Label(string.Format(LC.G("RequiringConfigurationFile"), NGSyncFoldersWindow.Title)); if (GUILayout.Button(LC.G("ShowPreferencesWindow")) == true) { Utility.ShowPreferencesWindowAt(Constants.PreferenceTitle); } return; } FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGSyncFoldersWindow.FreeAdContent); SyncFoldersSettings settings = HQ.Settings.Get <SyncFoldersSettings>(); // Guarantee there is always one in the list. if (settings.syncProfiles.Count == 0) { settings.syncProfiles.Add(new Profile() { name = "Profile 1" }); } this.currentProfile = Mathf.Clamp(this.currentProfile, 0, settings.syncProfiles.Count - 1); this.profile = settings.syncProfiles[this.currentProfile]; Rect r = default(Rect); if (NGSyncFoldersWindow.cachePath == null) { NGSyncFoldersWindow.cachePath = Path.Combine(Application.persistentDataPath, Path.Combine(Constants.InternalPackageTitle, string.Format(NGSyncFoldersWindow.CachedHashedFile, this.currentProfile))); } this.slavesList.list = this.profile.slaves; this.filtersList.list = this.profile.filters; r.width = this.position.width; r.height = Constants.SingleLineHeight; GUI.Box(r, string.Empty, GeneralStyles.Toolbar); r.width = 20F; if (GUI.Button(r, "", GeneralStyles.ToolbarDropDown) == true) { GenericMenu menu = new GenericMenu(); for (int i = 0; i < settings.syncProfiles.Count; i++) { menu.AddItem(new GUIContent((i + 1) + " - " + settings.syncProfiles[i].name), i == this.currentProfile, this.SwitchProfile, i); } menu.AddSeparator(""); menu.AddItem(new GUIContent(LC.G("Add")), false, this.AddProfile); menu.DropDown(r); GUI.FocusControl(null); } r.x += r.width + 4F; r.width = this.position.width - 20F - 100F - 4F; EditorGUI.BeginChangeCheck(); r.y += 2F; string name = EditorGUI.TextField(r, this.profile.name, GeneralStyles.ToolbarTextField); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(settings, "Rename profile"); this.profile.name = name; HQ.InvalidateSettings(); } r.y -= 2F; r.x += r.width; r.width = 100F; EditorGUI.BeginDisabledGroup(settings.syncProfiles.Count <= 1); { if (GUI.Button(r, LC.G("Erase"), GeneralStyles.ToolbarButton) == true && ((Event.current.modifiers & Constants.ByPassPromptModifier) != 0 || EditorUtility.DisplayDialog(LC.G("NGSyncFolders_EraseSave"), string.Format(LC.G("NGSyncFolders_EraseSaveQuestion"), this.profile.name), LC.G("Yes"), LC.G("No")) == true)) { this.EraseProfile(); this.Focus(); return; } } EditorGUI.EndDisabledGroup(); r.x = 0F; r.y += r.height + 5F; r.width = this.position.width; using (LabelWidthRestorer.Get(85F)) { EditorGUI.BeginChangeCheck(); string folderPath = NGEditorGUILayout.OpenFolderField(r, "Master Folder", this.profile.master.folderPath); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(settings, "Alter master path"); this.profile.master.folderPath = folderPath; HQ.InvalidateSettings(); } r.y += r.height + NGSyncFoldersWindow.Spacing; EditorGUI.BeginChangeCheck(); string relativePath = NGEditorGUILayout.OpenFolderField(r, "Relative Path", this.profile.relativePath, this.profile.master.folderPath, NGEditorGUILayout.FieldButtons.Open); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(settings, "Alter relative path"); this.profile.relativePath = relativePath; HQ.InvalidateSettings(); } r.y += r.height + NGSyncFoldersWindow.Spacing; this.PreviewPath(r, this.profile.master.GetFullPath(this.profile.relativePath)); r.y += r.height + NGSyncFoldersWindow.Spacing; r.height = this.slavesList.GetHeight(); this.slavesList.DoList(r); if (this.showSlaves == false) { r.y -= 16F; } r.y += r.height + NGSyncFoldersWindow.Spacing; } r.height = this.filtersList.GetHeight(); this.filtersList.DoList(r); if (this.showFilters == false) { if (Event.current.type == EventType.Repaint) { Rect r2 = r; r2.y += r2.height - 14F; r2.height = 16F; r2.width = 16F; EditorGUI.DrawRect(r2, EditorGUIUtility.isProSkin == true ? new Color(55F / 255F, 55F / 255F, 55F / 255F, 1F) : new Color(162F / 255F, 162F / 255F, 162F / 255F, 1F)); } r.y -= 16F; } r.y += r.height + NGSyncFoldersWindow.Spacing; if (string.IsNullOrEmpty(this.cacheFileSize) == true) { this.UpdateCacheFileSize(); } EditorGUI.BeginChangeCheck(); r.width -= 200F; r.height = 20F; bool useCache = EditorGUI.Toggle(r, this.cacheFileSize, this.profile.useCache); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(settings, "Toggle use cache"); this.profile.useCache = useCache; HQ.InvalidateSettings(); } if (this.cacheFileSize != "Use Cache") { r.x += r.width; r.width = 100F; if (GUI.Button(r, "Open", "ButtonLeft") == true) { EditorUtility.RevealInFinder(NGSyncFoldersWindow.cachePath); } r.x += r.width; if (GUI.Button(r, "Clear", "ButtonRight") == true) { System.IO.File.Delete(NGSyncFoldersWindow.cachePath); this.UpdateCacheFileSize(); } } r.y += r.height + NGSyncFoldersWindow.Spacing; bool hasActiveSlaves = false; for (int i = 0; i < this.profile.slaves.Count; i++) { if (this.profile.slaves[i].active == true) { hasActiveSlaves = true; break; } } EditorGUI.BeginDisabledGroup(hasActiveSlaves == false); { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { r.x = 10F; r.width = 150F; r.height = 32F; if (GUI.Button(r, this.mode == ButtonMode.Scan ? "Scan" : "Scan & Watch", "Button" /*"ButtonLeft"*/) == true) { this.Scan(); } //if (GUILayout.Button("☰", "ButtonRight", GUILayoutOptionPool.Height(32F), GUILayoutOptionPool.ExpandWidthFalse) == true) //{ // GenericMenu menu = new GenericMenu(); // menu.AddItem(new GUIContent("Scan"), this.mode == ButtonMode.Scan, () => this.mode = ButtonMode.Scan); // menu.AddItem(new GUIContent("Scan and Watch"), this.mode == ButtonMode.ScanAndWatch, () => this.mode = ButtonMode.ScanAndWatch); // menu.ShowAsContext(); //} } } EditorGUI.EndDisabledGroup(); if (this.profile.master.IsScanned == true) { using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton)) { r.x = this.position.width - r.width - 10F; if (GUI.Button(r, "Sync All", "Button") == true) { this.SyncAll(); } r.y += r.height + NGSyncFoldersWindow.Spacing; } } //if (this.mode == ButtonMode.ScanAndWatch) // EditorGUILayout.HelpBox("Scan and Watch may induce huge freeze after a compilation when watching a lot of files. This mode is not recommended for programmers.", MessageType.Warning); if (this.profile.master.IsScanned == true) { r.x = 0F; r.width = this.position.width; Rect bodyRect = r; bodyRect.height = this.position.height - r.y; Rect viewRect = new Rect { height = this.profile.master.GetHeight() }; for (int i = 0; i < this.profile.slaves.Count; i++) { if (this.profile.slaves[i].active == true) { viewRect.height += this.profile.slaves[i].GetHeight(this.profile.master); } } this.scrollPositionScan = GUI.BeginScrollView(bodyRect, this.scrollPositionScan, viewRect); { r.y = 0F; r.height = this.profile.master.GetHeight(); if (viewRect.height > r.height) { r.width -= 15F; } if (r.yMax > this.scrollPositionScan.y) { this.profile.master.OnGUI(r, 0, this.scrollPositionScan.y, this.scrollPositionScan.y + bodyRect.height); } r.y += r.height; for (int i = 0; i < this.profile.slaves.Count; i++) { if (this.profile.slaves[i].active == false) { continue; } r.height = this.profile.slaves[i].GetHeight(this.profile.master); if (r.yMax > this.scrollPositionScan.y) { this.profile.slaves[i].OnGUI(r, i + 1, this.scrollPositionScan.y, this.scrollPositionScan.y + bodyRect.height, this.profile.master); } r.y += r.height; if (r.y - this.scrollPositionScan.y > bodyRect.height) { break; } } } GUI.EndScrollView(); } FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro"); }
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(); } }
private void OnGUIPreferences(Rect r) { PrefsManager manager = this.prefManagers[this.currentManager]; float x = r.x; float width = r.width; bool hasLoaded = false; try { for (int k = 0; k < this.filteredIndexes.Count; k++) { if (r.y + r.height <= this.scrollPosition.y) { r.y += r.height; continue; } int i = this.filteredIndexes[k]; string key = manager.keys[i]; object value = manager.values[i]; if (value == null) { if (hasLoaded == false) { hasLoaded = true; manager.BeginLoadFromRegistrar(); } manager.LoadValueFromRegistrar(i); value = manager.values[i]; } r.x = x; r.width = 20F; if (value == System.Type.Missing || (GUI.Button(r, "X", GeneralStyles.ToolbarCloseButton) == true && ((Event.current.modifiers & Constants.ByPassPromptModifier) != 0 || EditorUtility.DisplayDialog(LC.G("NGPrefs_DeletePref"), string.Format(LC.G("NGPrefs_DeletePrefConfirm"), key), LC.G("Yes"), LC.G("No")) == true))) { manager.DeleteKey(i); this.UpdateFilteredIndexes(); if (this.editingStringIndex == i) { this.editingStringIndex = -1; } break; } r.x += r.width; this.content.text = key; this.content.tooltip = key; bool isAltered = ((value is int && (int)value != manager.GetInt(key)) || (value is float && (float)value != manager.GetFloat(key)) || (value is string && (string)value != manager.GetString(key))); r.width = (isAltered == true) ? width - r.x - 60F : width - r.x; using (BgColorContentRestorer.Get(isAltered, NGPrefsWindow.AlteredPrefBackgroundColor)) { if (value is int) { manager.values[i] = EditorGUI.IntField(r, this.content, (int)value); } else if (value is string) { string content = (string)value; if (content.Length <= NGPrefsWindow.MaxStringLength) { manager.values[i] = EditorGUI.TextField(r, this.content, content); } else { EditorGUI.LabelField(r, this.content); r.x += labelWidth; r.width -= labelWidth; if (this.editingStringIndex != i) { if (GUI.Button(r, "String has more than " + NGPrefsWindow.MaxStringLength + " chars. Click to edit.") == true) { this.editingStringIndex = i; this.tempFilePath = Path.Combine(Application.temporaryCachePath, Path.GetRandomFileName() + ".txt"); File.WriteAllText(this.tempFilePath, content); this.lastFileChange = DateTime.Now; using (var md5 = MD5.Create()) using (var stream = File.OpenRead(this.tempFilePath)) { this.lastHash = md5.ComputeHash(stream); } EditorUtility.OpenWithDefaultApp(this.tempFilePath); Utility.RegisterIntervalCallback(this.CheckTempFile, 100); } } else { if (GUI.Button(r, "Editing... Last changed at " + this.lastFileChange.ToString("HH:mm:ss") + ". Click to stop.") == true) { this.editingStringIndex = -1; Utility.UnregisterIntervalCallback(this.CheckTempFile); } } } } else if (value is float) { manager.values[i] = EditorGUI.FloatField(r, this.content, (float)value); } } r.x += r.width; if (isAltered == true) { r.width = 30F; if (GUI.Button(r, this.resetContent, GeneralStyles.ToolbarAltButton) == true) { GUI.FocusControl(null); if (manager.HasKey(key) == false) { try { manager.LoadPreferences(); this.UpdateFilteredIndexes(); } catch (Exception ex) { this.errorPopup.exception = ex; } break; } else if (value is int) { manager.values[i] = manager.GetInt(key); } else if (value is float) { manager.values[i] = manager.GetFloat(key); } else if (value is string) { manager.values[i] = manager.GetString(key); } } r.x += r.width; if (GUI.Button(r, this.applyContent, GeneralStyles.ToolbarValidButton) == true) { if (value is int) { manager.SetInt(key, (int)value); } else if (value is float) { manager.SetFloat(key, (float)value); } else if (value is string) { manager.SetString(key, (string)value); } } } r.y += r.height; if (r.y - this.scrollPosition.y >= this.bodyRect.height) { break; } } } catch (Exception ex) { this.errorPopup.exception = ex; } finally { if (hasLoaded == true) { manager.EndLoadFromRegistrar(); } } }
public void OnGUI(Rect r, float minY, float maxY, File model) { if (this.isDir == false) { return; } if (this.canDisplay == false) { GUI.Label(r, "No change detected."); return; } r.height = 16F; if (Event.current.type == EventType.Repaint && r.Contains(Event.current.mousePosition) == true) { EditorGUI.DrawRect(r, File.HighlightBackground); } else if (Event.current.type == EventType.MouseMove && r.Contains(Event.current.mousePosition) == true) { Utility.RepaintEditorWindow(typeof(NGSyncFoldersWindow)); } EditorGUI.BeginChangeCheck(); this.open = EditorGUI.Foldout(r, this.open, this.name, true); if (EditorGUI.EndChangeCheck() == true) { this.InvalidateHeight(); } if (this.open == false) { return; } r.y += r.height; if (r.y > maxY) { return; } float w = r.width; EditorGUI.indentLevel++; for (int i = 0; i < this.children.Count; i++) { if (this.children[i].isDir == true) { if (this.children[i].canDisplay == true) { File m = this.children[i].GetCacheModel(model, this.children[i].name); r.height = this.children[i].GetHeight(m); if (r.yMax >= minY) { this.children[i].OnGUI(r, minY, maxY, m); } r.y += r.height; if (r.y > maxY) { break; } } } else { if (this.isMaster == true) { if (this.children[i].masterState != MasterState.Same) { r.height = 16F; if (r.yMax >= minY) { Color color = default(Color); if (this.children[i].masterState == MasterState.Created) { color = NGSyncFoldersWindow.CreateColor; } else if (this.children[i].masterState == MasterState.Altered) { color = NGSyncFoldersWindow.RestoreColor; } else if (this.children[i].masterState == MasterState.Deleted) { color = NGSyncFoldersWindow.DeleteColor; } if (Event.current.type == EventType.Repaint && r.Contains(Event.current.mousePosition) == true) { EditorGUI.DrawRect(r, color); } else if (Event.current.type == EventType.MouseMove && r.Contains(Event.current.mousePosition) == true) { Utility.RepaintEditorWindow(typeof(NGSyncFoldersWindow)); } EditorGUI.LabelField(r, Utility.Color(this.children[i].name, color), GeneralStyles.RichLabel); } r.y += r.height; if (r.y > maxY) { break; } } } else { File m = this.children[i].GetCacheModel(model, this.children[i].name); Action action = this.children[i].ChooseAction(m); if (action != Action.Nothing) { r.height = 16F; if (r.yMax >= minY) { Color color = default(Color); if (action == Action.Create) { color = NGSyncFoldersWindow.CreateColor; } else if (action == Action.Change) { color = NGSyncFoldersWindow.RestoreColor; } else if (action == Action.Delete) { color = NGSyncFoldersWindow.DeleteColor; } if (Event.current.type == EventType.Repaint && r.Contains(Event.current.mousePosition) == true) { EditorGUI.DrawRect(r, color * .2F); } else if (Event.current.type == EventType.MouseMove && r.Contains(Event.current.mousePosition) == true) { Utility.RepaintEditorWindow(typeof(NGSyncFoldersWindow)); } r.width -= 75F; if (this.children[i].actionException != null) { r.width -= 75F; } EditorGUI.LabelField(r, Utility.Color(this.children[i].name, color), GeneralStyles.RichLabel); r.x += r.width; if (this.children[i].actionException != null) { r.width = 75F; using (BgColorContentRestorer.Get(Color.red)) { if (GUI.Button(r, "Error") == true) { ErrorPopup e = new ErrorPopup(NGSyncFoldersWindow.Title); e.exception = this.children[i].actionException; e.OpenError(r); } } r.x += r.width; } using (BgColorContentRestorer.Get(action == Action.Create ? NGSyncFoldersWindow.CreateColor : (action == Action.Change ? NGSyncFoldersWindow.RestoreColor : NGSyncFoldersWindow.DeleteColor))) { r.width = 75F; if (GUI.Button(r, action.ToString()) == true) { this.children[i].Sync(m); } r.x -= w - 75F; if (this.actionException != null) { r.x -= 75F; } r.width = w; } } r.y += r.height; if (r.y > maxY) { break; } } } } } EditorGUI.indentLevel--; }
private void DrawProject() { GUILayout.Space(5F); EditorGUILayout.BeginVertical("ButtonLeft"); { this.openAutoRecovery = EditorGUILayout.Foldout(this.openAutoRecovery, "Recovery Settings (" + Enum.GetName(typeof(RecoveryMode), this.recoveryMode) + ")"); if (this.openAutoRecovery == true) { this.recoveryMode = (RecoveryMode)EditorGUILayout.EnumPopup("Recovery Mode", this.recoveryMode); if (this.recoveryMode == RecoveryMode.Automatic) { this.promptOnPause = EditorGUILayout.Toggle(this.promptOnPauseContent, this.promptOnPause); this.useCache = EditorGUILayout.Toggle(this.useCacheContent, this.useCache); this.supaFast = EditorGUILayout.Toggle(supaFastContent, this.supaFast); this.recoveryLogFilePath = NGEditorGUILayout.SaveFileField("Recovery Log File", this.recoveryLogFilePath); } GUILayout.Space(5F); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button("Scan", GeneralStyles.BigButton) == true) { string[] assets = AssetDatabase.GetAllAssetPaths(); this.hasResult = true; this.selectedMissing = -1; this.missings.Clear(); try { for (int i = 0; i < assets.Length; i++) { if (assets[i].EndsWith(".prefab") == false) { continue; } if (EditorUtility.DisplayCancelableProgressBar(NGMissingScriptRecoveryWindow.NormalTitle, "Scanning " + assets[i], (float)i / (float)assets.Length) == true) { break; } Object[] content = AssetDatabase.LoadAllAssetsAtPath(assets[i]); for (int j = 0; j < content.Length; j++) { GameObject go = content[j] as GameObject; if (go != null) { Component[] components = go.GetComponents <Component>(); for (int k = 0; k < components.Length; k++) { if (components[k] == null) { this.missings.Add(new MissingGameObject(go)); break; } } } } } } finally { EditorUtility.ClearProgressBar(); } return; } } GUILayout.FlexibleSpace(); if (this.cachedComponentFixes.Count > 0) { if (GUILayout.Button("Clear Recovery Cache (" + this.cachedComponentFixes.Count + " elements)", GeneralStyles.BigButton) == true) { this.cachedComponentFixes.Clear(); } } } EditorGUILayout.EndHorizontal(); if (this.hasResult == true) { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { GUILayout.Label("Result"); GUILayout.FlexibleSpace(); if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton) == true) { this.hasResult = false; } } EditorGUILayout.EndHorizontal(); if (this.missings.Count == 0) { GUILayout.Label("No missing script found."); } else { this.scrollPositionResult = EditorGUILayout.BeginScrollView(this.scrollPositionResult); { for (int i = 0; i < this.missings.Count; i++) { EditorGUILayout.BeginHorizontal(); { NGEditorGUILayout.PingObject(this.missings[i].path, this.missings[i].gameObject, GeneralStyles.LeftButton); if (GUILayout.Button("Fix", GUILayoutOptionPool.Width(75F)) == true) { this.selectedMissing = i; this.tab = 0; this.Diagnose(this.missings[i].gameObject); } } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (this.recoveryMode == RecoveryMode.Automatic) { EditorGUILayout.HelpBox("Backup your project before\ndoing any automatic recovery.", MessageType.Warning); } using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton)) { if (GUILayout.Button("Start Recovery", GeneralStyles.BigButton) == true) { Utility.StartBackgroundTask(this.RecoveryTask()); } } } EditorGUILayout.EndHorizontal(); } } }
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); }
private static void DrawRow(int i, int foldType, bool fold, string content, string collapseCount) { LogSettings settings = HQ.Settings.Get <LogSettings>(); Rect r = GUILayoutUtility.GetRect(0F, settings.height, settings.Style); float originX = r.x; float originWidth = r.width; if (Event.current.type == EventType.Repaint) { if (i == 0) { EditorGUI.DrawRect(r, settings.selectedBackground); } else if ((i & 1) == 0) { EditorGUI.DrawRect(r, settings.evenBackground); } else { EditorGUI.DrawRect(r, settings.oddBackground); } } r.x += 2F; r.width = 16F; Color foldoutColor = Color.white; bool isDefaultLog = false; if (foldType == 1) { foldoutColor = ConsoleConstants.WarningFoldoutColor; } else if (foldType == 2) { foldoutColor = ConsoleConstants.ErrorFoldoutColor; } else if (foldType == 3) { foldoutColor = ConsoleConstants.ExceptionFoldoutColor; } else { isDefaultLog = true; } using (BgColorContentRestorer.Get(!isDefaultLog, foldoutColor)) { EditorGUI.Foldout(r, fold, string.Empty); } r.x -= 2F; r.width = 3F; if (isDefaultLog == false) { EditorGUI.DrawRect(r, foldoutColor); } r.width = 16F; r.xMin += r.width; // Draw time. if (settings.displayTime == true) { Utility.content.text = DateTime.Now.ToString(settings.timeFormat); r.width = settings.TimeStyle.CalcSize(Utility.content).x; GUI.Label(r, Utility.content, settings.TimeStyle); r.x += r.width; } // Draw frame count. if (settings.displayFrameCount == true) { Utility.content.text = Time.frameCount.ToString(); r.width = settings.TimeStyle.CalcSize(Utility.content).x; GUI.Label(r, Utility.content, settings.TimeStyle); r.x += r.width; } // Draw rendered frame count. if (settings.displayRenderedFrameCount == true) { Utility.content.text = Time.renderedFrameCount.ToString(); r.width = settings.TimeStyle.CalcSize(Utility.content).x; GUI.Label(r, Utility.content, settings.TimeStyle); r.x += r.width; } r.width = originWidth - (r.x - originX); GUI.Button(r, content, settings.Style); if (collapseCount != string.Empty) { // Draw collapse count. Utility.content.text = collapseCount; r.xMin += r.width - settings.CollapseLabelStyle.CalcSize(Utility.content).x; GUI.Label(r, Utility.content, settings.CollapseLabelStyle); } }
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"); }
public override void DrawRow(RowsDrawer rowsDrawer, Rect r, int streamIndex, bool?collapse) { LogSettings settings = HQ.Settings.Get <LogSettings>(); float originWidth = r.width - rowsDrawer.verticalScrollbarWidth /* + rowsDrawer.currentVars.scrollX*/; // Draw highlight. //r.x = rowsDrawer.currentVars.scrollX; r.width = originWidth; r.height = settings.height; this.DrawBackground(rowsDrawer, r, streamIndex); // Handle row events. if (r.Contains(Event.current.mousePosition) == true) { if (Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDrag) { 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"); } if (rowsDrawer.RowHovered != null) { r.y -= rowsDrawer.currentVars.scrollbar.Offset; rowsDrawer.RowHovered(r, this); r.y += rowsDrawer.currentVars.scrollbar.Offset; } } else if (Event.current.type == EventType.MouseDown) { if (rowsDrawer.RowClicked != null) { r.y -= rowsDrawer.currentVars.scrollbar.Offset; rowsDrawer.RowClicked(r, this); r.y += rowsDrawer.currentVars.scrollbar.Offset; } } } //r.x = 0F; if (RowsDrawer.GlobalBeforeFoldout != null) { //r.width = originWidth - r.x; r = RowsDrawer.GlobalBeforeFoldout(rowsDrawer, r, streamIndex, this); } if (rowsDrawer.BeforeFoldout != null) { r.width = originWidth - r.x; r = rowsDrawer.BeforeFoldout(r, streamIndex, this); } // The drag position needs to be often reset. To ensure no drag start. if (Event.current.type == EventType.MouseUp) { Utility.position2D = Vector2.zero; } if (Event.current.type == EventType.MouseDown) { Utility.position2D = Vector2.zero; if (Event.current.button == 0 && r.Contains(Event.current.mousePosition) == true) { Utility.position2D = Event.current.mousePosition; if (this.log.instanceID != 0) { DragAndDrop.objectReferences = new Object[] { EditorUtility.InstanceIDToObject(this.log.instanceID) }; DragAndDrop.SetGenericData(Utility.DragObjectDataName, this.log.instanceID); } } } Color foldoutColor = Color.white; bool isDefaultLog = false; if ((this.log.mode & Mode.ScriptingException) != 0) { if (HQ.Settings.Get <GeneralSettings>().differentiateException == false) { foldoutColor = ConsoleConstants.ErrorFoldoutColor; } else { foldoutColor = ConsoleConstants.ExceptionFoldoutColor; } } else if ((this.log.mode & (Mode.ScriptCompileError | Mode.ScriptingError | Mode.Fatal | Mode.Error | Mode.Assert | Mode.AssetImportError | Mode.ScriptingAssertion)) != 0) { foldoutColor = ConsoleConstants.ErrorFoldoutColor; } else if ((this.log.mode & (Mode.ScriptCompileWarning | Mode.ScriptingWarning | Mode.AssetImportWarning)) != 0) { foldoutColor = ConsoleConstants.WarningFoldoutColor; } else { isDefaultLog = true; } bool isOpened = rowsDrawer.rowsData.ContainsKey(this); // Draw foldout. r.x += 2F; r.width = 16F; EditorGUI.BeginDisabledGroup(this.HasStackTrace == false); { using (BgColorContentRestorer.Get(!isDefaultLog, foldoutColor)) { EditorGUI.BeginChangeCheck(); EditorGUI.Foldout(r, (bool)isOpened, ""); if (EditorGUI.EndChangeCheck() == true) { if (isOpened == false) { rowsDrawer.rowsData.Add(this, true); } else { rowsDrawer.rowsData.Remove(this); } isOpened = !isOpened; GUI.FocusControl(null); rowsDrawer.InvalidateViewHeight(); } } r.x -= 2F; r.width = 3F; if (isDefaultLog == false) { EditorGUI.DrawRect(r, foldoutColor); } r.width = 16F; } EditorGUI.EndDisabledGroup(); r.x = r.width; if (this.log.instanceID != 0) { if (this.icon == null) { this.icon = Utility.GetIcon(this.log.instanceID); if (this.icon == null) { this.icon = InternalEditorUtility.GetIconForFile(this.log.file); } } if (icon != null) { r.width = settings.height; GUI.DrawTexture(r, icon); r.x += r.width; } } if (RowsDrawer.GlobalBeforeLog != null) { r.width = originWidth - r.x; r = RowsDrawer.GlobalBeforeLog(r, streamIndex, this); } if (rowsDrawer.BeforeLog != null) { r.width = originWidth - r.x; r = rowsDrawer.BeforeLog(r, streamIndex, this); } r.width = originWidth - r.x; // Handle mouse inputs. if (r.Contains(Event.current.mousePosition) == true) { // Toggle on middle click. if (Event.current.type == EventType.MouseDown && Event.current.button == 2) { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { if (Event.current.control == false) { rowsDrawer.currentVars.ClearSelection(); } rowsDrawer.currentVars.AddSelection(streamIndex); if (Event.current.control == false) { rowsDrawer.FitFocusedLogInScreen(streamIndex); } GUI.FocusControl(null); } if (rowsDrawer.rowsData.ContainsKey(this) == false) { rowsDrawer.rowsData.Add(this, true); } else { rowsDrawer.rowsData.Remove(this); } //this.isOpened = !this.isOpened; rowsDrawer.InvalidateViewHeight(); Event.current.Use(); } // Show menu on right click up. else if (Event.current.type == EventType.MouseUp && Event.current.button == 1 && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent(LC.G("CopyLine")), false, rowsDrawer.MenuCopyLine, this); menu.AddItem(new GUIContent(LC.G("CopyLog")), false, rowsDrawer.MenuCopyLog, this); if (string.IsNullOrEmpty(this.StackTrace) == false) { menu.AddItem(new GUIContent(LC.G("CopyStackTrace")), false, rowsDrawer.MenuCopyStackTrace, this); } menu.AddItem(new GUIContent("Advance Copy Shift+C"), false, rowsDrawer.OpenAdvanceCopy); if (rowsDrawer.currentVars.CountSelection >= 2) { menu.AddItem(new GUIContent(LC.G("ExportSelection")), false, rowsDrawer.MenuExportSelection, this); } if (RowsDrawer.GlobalLogContextMenu != null) { RowsDrawer.GlobalLogContextMenu(menu, rowsDrawer, streamIndex, this); } if (rowsDrawer.LogContextMenu != null) { rowsDrawer.LogContextMenu(menu, this); } menu.ShowAsContext(); Event.current.Use(); } // Focus on right click down. else if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { // Handle multi-selection. if (Event.current.control == true) { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { rowsDrawer.currentVars.AddSelection(streamIndex); } } else { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { rowsDrawer.currentVars.ClearSelection(); rowsDrawer.currentVars.AddSelection(streamIndex); } rowsDrawer.FitFocusedLogInScreen(streamIndex); GUI.FocusControl(null); } Event.current.Use(); } // Focus on left click. else if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { // Set the selection to the log's object if available. if (this.log.instanceID != 0 && (Event.current.modifiers & settings.selectObjectOnModifier) != 0) { Selection.activeInstanceID = this.log.instanceID; } // Go to line if force focus is available. else if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { RowUtility.GoToLine(this, this.log, true); } // Handle multi-selection. if (Event.current.control == true && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { rowsDrawer.currentVars.RemoveSelection(streamIndex); } else { if (Event.current.shift == true) { rowsDrawer.currentVars.WrapSelection(streamIndex); } else if (Event.current.control == false) { if (settings.alwaysDisplayLogContent == false && rowsDrawer.currentVars.CountSelection != 1) { rowsDrawer.bodyRect.height -= rowsDrawer.currentVars.rowContentHeight + ConsoleConstants.RowContentSplitterHeight; } else { // Reset last click when selection changes. if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { RowUtility.LastClickTime = 0; } } rowsDrawer.currentVars.ClearSelection(); } if (Event.current.shift == false) { rowsDrawer.currentVars.AddSelection(streamIndex); } if (Event.current.control == false) { rowsDrawer.FitFocusedLogInScreen(streamIndex); } GUI.FocusControl(null); Event.current.Use(); } } // Handle normal behaviour on left click up. else if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { // Go to line on double click. if (RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup && RowUtility.LastClickIndex == streamIndex && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { bool focus = false; if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { focus = true; } RowUtility.GoToLine(this, this.log, focus); } // Ping on simple click. else if (this.log.instanceID != 0) { EditorGUIUtility.PingObject(this.log.instanceID); } RowUtility.LastClickTime = EditorApplication.timeSinceStartup; RowUtility.LastClickIndex = streamIndex; GUI.FocusControl(null); RowUtility.drawingWindow.Repaint(); Event.current.Use(); } } r = this.DrawPreLogData(rowsDrawer, r); r.width = originWidth - r.x; this.DrawLog(r, streamIndex); r = this.DrawCollapseLabel(r, collapse); if (RowsDrawer.GlobalAfterLog != null) { r = RowsDrawer.GlobalAfterLog(r, streamIndex, this); } if (rowsDrawer.AfterLog != null) { r = rowsDrawer.AfterLog(r, streamIndex, this); } r.y += r.height; if (isOpened == true) { r.x = 0F; r.width = originWidth; RowUtility.DrawStackTrace(this, rowsDrawer, r, streamIndex, this); } }
public void Draw(Rect r) { Rect viewRect = default(Rect); viewRect.height = Constants.SingleLineHeight + NGAssetFinderWindow.Spacing; if (Conf.DebugMode != Conf.DebugState.None) { viewRect.height += Constants.SingleLineHeight + Constants.SingleLineHeight + NGAssetFinderWindow.Spacing + NGAssetFinderWindow.Spacing; } if (this.aborted == true) { viewRect.height += SearchResult.WarningMessageHeight + NGAssetFinderWindow.Spacing; } if (this.aFileHasFailed.Count > 0) { viewRect.height += SearchResult.WarningMessageHeight + NGAssetFinderWindow.Spacing; } if (this.aMemberHasFailed.Count > 0) { viewRect.height += SearchResult.WarningMessageHeight + NGAssetFinderWindow.Spacing; } if (this.matchedInstancesInScene.Count > 0) { viewRect.height += Constants.SingleLineHeight + NGAssetFinderWindow.Spacing; for (int i = 0; i < this.matchedInstancesInScene.Count; i++) { viewRect.height += this.matchedInstancesInScene[i].GetHeight(); } } if (this.matchedInstancesInProject.Count > 0) { viewRect.height += Constants.SingleLineHeight + NGAssetFinderWindow.Spacing + (this.matchedScenes.Count) * Constants.SingleLineHeight + NGAssetFinderWindow.Spacing; for (int i = 0; i < this.matchedInstancesInProject.Count; i++) { viewRect.height += this.matchedInstancesInProject[i].GetHeight(); } } this.scrollPosition = GUI.BeginScrollView(r, this.scrollPosition, viewRect); { r.y = 0F; r.width -= viewRect.height > r.height ? 16F : 0F; r.height = Constants.SingleLineHeight; float width = r.width; if (Conf.DebugMode != Conf.DebugState.None) { EditorGUI.LabelField(r, "Time:", this.searchTime.ToString()); r.y += r.height + NGAssetFinderWindow.Spacing; EditorGUI.LabelField(r, "Potential Matches:", this.potentialMatchesCount.ToCachedString()); r.y += r.height + NGAssetFinderWindow.Spacing; if (this.effectiveMatchesCount > 0) { EditorGUI.LabelField(r, "Matches:", this.effectiveMatchesCount.ToCachedString()); } else { EditorGUI.LabelField(r, "Matches:", "No result"); } } else { if (this.effectiveMatchesCount > 0) { GUI.Label(r, "Matches: " + this.effectiveMatchesCount.ToCachedString()); } else { GUI.Label(r, "Matches: No result"); } } r.y += r.height + NGAssetFinderWindow.Spacing; if (this.aborted == true) { r.width = width; r.height = SearchResult.WarningMessageHeight; EditorGUI.HelpBox(r, "The search has been aborted.", MessageType.Warning); r.y += r.height + NGAssetFinderWindow.Spacing; } if (this.aFileHasFailed.Count > 0) { r.width = width - SearchResult.WarningSeeButtonWidth - NGAssetFinderWindow.Margin; r.height = SearchResult.WarningMessageHeight; EditorGUI.HelpBox(r, SearchResult.AFileHasFailedMessage, MessageType.Warning); r.x += r.width; r.width = SearchResult.WarningSeeButtonWidth; if (GUI.Button(r, "See") == true) { PopupWindow.Show(new Rect(Event.current.mousePosition + new Vector2(SearchResult.PopupXOffset, SearchResult.PopupYOffset), Vector2.zero), new ViewWarningsPopup(this.aFileHasFailed, null)); } r.y += r.height + NGAssetFinderWindow.Spacing; } if (this.aMemberHasFailed.Count > 0) { r.width = width - SearchResult.WarningSeeButtonWidth - NGAssetFinderWindow.Margin; r.height = SearchResult.WarningMessageHeight; EditorGUI.HelpBox(r, SearchResult.AMemberHasFailedMessage, MessageType.Warning); r.x += r.width; r.width = SearchResult.WarningSeeButtonWidth; if (GUI.Button(r, "See") == true) { PopupWindow.Show(new Rect(Event.current.mousePosition + new Vector2(SearchResult.PopupXOffset, SearchResult.PopupYOffset), Vector2.zero), new ViewWarningsPopup(null, this.aMemberHasFailed)); } r.y += r.height + NGAssetFinderWindow.Spacing; } try { if (Event.current.type == EventType.MouseMove) { this.window.Repaint(); } r.x = 0F; r.width = width; if (this.matchedInstancesInScene.Count > 0) { r.height = Constants.SingleLineHeight; EditorGUI.LabelField(r, "Scene matches", GeneralStyles.ToolbarButton); if (this.window.canReplace == true) { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { r.width = width * .34F; r.x = width - r.width; if (GUI.Button(r, "Replace All") == true) { this.ReplaceReferences(false); } r.x = 0F; r.width = width; } } r.y += r.height + NGAssetFinderWindow.Spacing; for (int i = 0; i < this.matchedInstancesInScene.Count; i++) { r.height = this.matchedInstancesInScene[i].GetHeight(); this.matchedInstancesInScene[i].Draw(this.window, r); r.y += r.height; } } if (this.matchedInstancesInProject.Count > 0 || this.matchedScenes.Count > 0) { r.height = Constants.SingleLineHeight; EditorGUI.LabelField(r, "Project matches", GeneralStyles.ToolbarButton); if (this.window.canReplace == true) { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { r.width = width * .34F; r.x = width - r.width; if (GUI.Button(r, "Replace") == true) { this.ReplaceReferences(false); } r.x = 0F; r.width = width; } } r.y += r.height + NGAssetFinderWindow.Spacing; for (int i = 0; i < this.matchedScenes.Count; i++) { this.matchedScenes[i].Draw(this, this.window, r); r.y += r.height; } for (int i = 0; i < this.matchedInstancesInProject.Count; i++) { r.height = this.matchedInstancesInProject[i].GetHeight(); this.matchedInstancesInProject[i].Draw(this.window, r); r.y += r.height; } } } catch (Exception ex) { this.window.errorPopup.exception = ex; } } GUI.EndScrollView(); }
protected virtual void OnGUI() { FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGShaderFinderWindow.FreeAdContent); Rect r = this.position; r.x = 0F; r.y = 0F; r.height = NGShaderFinderWindow.SearchButtonHeight; EditorGUI.BeginDisabledGroup(this.isSearching); { r.height = Constants.SingleLineHeight; using (LabelWidthRestorer.Get(100F)) { r.width = this.position.width - NGShaderFinderWindow.FindButtonWidth - NGShaderFinderWindow.FindButtonLeftSpacing; EditorGUI.BeginChangeCheck(); Shader newTarget = EditorGUI.ObjectField(r, "Find Shader", this.targetShader, typeof(Shader), false) as Shader; if (EditorGUI.EndChangeCheck() == true) { this.targetShader = newTarget; } } r.y += r.height + NGShaderFinderWindow.Spacing; r.width = NGShaderFinderWindow.TargetReplaceLabelWidth; this.canReplace = GUI.Toggle(r, this.canReplace, "Replace With"); r.x += r.width; EditorGUI.BeginDisabledGroup(!this.canReplace); { r.width = this.position.width - r.x - NGShaderFinderWindow.SwitchShaderButtonWidth - NGShaderFinderWindow.FindButtonWidth - NGShaderFinderWindow.FindButtonLeftSpacing; this.replaceShader = EditorGUI.ObjectField(r, this.replaceShader, typeof(Shader), false) as Shader; } EditorGUI.EndDisabledGroup(); r.x += r.width; r.width = NGShaderFinderWindow.SwitchShaderButtonWidth; if (GUI.Button(r, "⇅", GeneralStyles.BigFontToolbarButton) == true) { Shader tmp = this.replaceShader; this.replaceShader = this.targetShader; this.targetShader = tmp; } r.yMin -= r.height + NGShaderFinderWindow.Spacing; r.width = NGShaderFinderWindow.FindButtonWidth; r.x = this.position.width - NGShaderFinderWindow.FindButtonWidth; EditorGUI.BeginDisabledGroup(this.targetShader == null || this.isSearching == true); { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUI.Button(r, "Find") == true) { this.FindReferences(); } } } EditorGUI.EndDisabledGroup(); r.y += r.height + NGShaderFinderWindow.Spacing; } EditorGUI.EndDisabledGroup(); if (this.canReplace == true) { EditorGUI.BeginDisabledGroup(this.isSearching == true || this.hasResult == false); { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { r.x = 0F; r.width = this.position.width * .5F; if (GUI.Button(r, "Replace") == true) { this.ReplaceReferences(true); } r.x += r.width; if (GUI.Button(r, "Set all") == true) { this.ReplaceReferences(false); } r.y += r.height + NGShaderFinderWindow.Spacing + NGShaderFinderWindow.Spacing; } } EditorGUI.EndDisabledGroup(); } r.x = 0F; r.width = this.position.width; if (this.hasResult == true) { r.height = Constants.SingleLineHeight; GUI.Box(r, string.Empty, GeneralStyles.Toolbar); GUI.Label(r, this.resultsHeaderLabel); using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton)) { r.xMin = r.xMax - NGShaderFinderWindow.ClearButtonWidth; if (GUI.Button(r, "Clear", GeneralStyles.ToolbarButton) == true) { this.ClearResults(); } } r.y += r.height + NGShaderFinderWindow.Spacing; r.x = 0F; r.width = this.position.width; Rect bodyRect = r; bodyRect.height = this.position.height - r.y; Rect viewRect = new Rect(0F, 0F, 0F, (Constants.SingleLineHeight + NGShaderFinderWindow.Spacing) * this.results.Count - NGShaderFinderWindow.Spacing); this.scrollPosition = GUI.BeginScrollView(bodyRect, this.scrollPosition, viewRect); { float w = r.width - (viewRect.height > bodyRect.height ? 16F : 0F); r.y = 0F; r.height = Constants.SingleLineHeight; for (int i = 0; i < this.results.Count; i++) { if (r.y + r.height + NGShaderFinderWindow.Spacing <= this.scrollPosition.y) { r.y += r.height + NGShaderFinderWindow.Spacing; continue; } r.x = 0F; r.width = w - NGShaderFinderWindow.PingButtonWidth; EditorGUI.BeginChangeCheck(); Shader o = EditorGUI.ObjectField(r, this.resultsName[i], this.results[i].shader, typeof(Shader), false) as Shader; if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(this.results[i], "Replace Material shader"); this.results[i].shader = o; EditorUtility.SetDirty(this.results[i]); } r.x += r.width; r.width = NGShaderFinderWindow.PingButtonWidth; NGEditorGUILayout.PingObject(r, LC.G("Ping"), this.results[i]); r.y += r.height + NGShaderFinderWindow.Spacing; if (r.y - this.scrollPosition.y > bodyRect.height) { break; } } } GUI.EndScrollView(); } FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro"); }
public override Rect OnGUI(Rect r) { if (SampleStream.startModeTypes == null) { Type type = typeof(StartMode); List <Type> listTypes = new List <Type>(2); List <string> listNames = new List <string>(2); foreach (Type c in Utility.EachNGTSubClassesOf(type)) { listTypes.Add(c); if (c.Name.EndsWith(type.Name) == true) { listNames.Add(Utility.NicifyVariableName(c.Name.Remove(c.Name.Length - type.Name.Length, type.Name.Length))); } else { listNames.Add(Utility.NicifyVariableName(c.Name)); } } SampleStream.startModeTypes = listTypes.ToArray(); SampleStream.startModeNames = listNames.ToArray(); type = typeof(EndMode); listTypes.Clear(); listNames.Clear(); foreach (Type c in Utility.EachNGTSubClassesOf(type)) { listTypes.Add(c); if (c.Name.EndsWith(type.Name) == true) { listNames.Add(Utility.NicifyVariableName(c.Name.Remove(c.Name.Length - type.Name.Length, type.Name.Length))); } else { listNames.Add(Utility.NicifyVariableName(c.Name)); } } SampleStream.endModeTypes = listTypes.ToArray(); SampleStream.endModeNames = listNames.ToArray(); listTypes.Clear(); listNames.Clear(); this.startModes = new StartMode[SampleStream.startModeTypes.Length]; for (int i = 0; i < this.startModes.Length; i++) { this.startModes[i] = (StartMode)Activator.CreateInstance(SampleStream.startModeTypes[i]); this.startModes[i].Init(this); } this.endModes = new EndMode[SampleStream.endModeTypes.Length]; for (int i = 0; i < this.endModes.Length; i++) { this.endModes[i] = (EndMode)Activator.CreateInstance(SampleStream.endModeTypes[i]); this.endModes[i].Init(this); } } Rect rectModes = r; r.width = rectModes.width - SampleStream.ResetButtonWidth - SampleStream.ConditionSpacing - SampleStream.ConditionSpacing; r.width *= .5F; r.height = Constants.SingleLineHeight; using (BgColorContentRestorer.Get(this.hasStarted, Color.green)) this.currentStartMode = EditorGUI.Popup(r, LC.G("SampleStream_StartMode"), this.currentStartMode, SampleStream.startModeNames); r.y += r.height; GUILayout.BeginArea(r); { this.startModes[this.currentStartMode].OnGUI(); } GUILayout.EndArea(); r.y -= r.height; r.x += r.width + SampleStream.ConditionSpacing; using (BgColorContentRestorer.Get(this.hasEnded, Color.green)) this.currentEndMode = EditorGUI.Popup(r, LC.G("SampleStream_EndMode"), this.currentEndMode, SampleStream.endModeNames); r.y += r.height; GUILayout.BeginArea(r); { this.endModes[this.currentEndMode].OnGUI(); } GUILayout.EndArea(); r.x += r.width + SampleStream.ConditionSpacing; r.y -= r.height; r.width = SampleStream.ResetButtonWidth; r.height = Constants.SingleLineHeight + Constants.SingleLineHeight; if (GUI.Button(r, LC.G("Reset")) == true) { this.Clear(); } r.y += r.height; r.x = rectModes.x; r.height = rectModes.height - (r.y - rectModes.y); r.width = rectModes.width; return(base.OnGUI(r)); }
public Rect OnGUI(Rect r, bool compact) { 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")); } float xMax = r.xMax; SearchMode mode; GUI.Box(r, string.Empty, GeneralStyles.Toolbar); if (Event.current.type == EventType.ValidateCommand) { if (Event.current.commandName == "Find") { GUI.FocusControl("keyword"); EditorGUIUtility.editingTextField = true; Event.current.Use(); } } else if (Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.F) { if (this.keyword.Length > 0) { GUI.changed = true; this.keyword = string.Empty; this.searchPatterns = null; this.cachedResults.Clear(); this.CheckRegex(); } } } if (compact == false) { r.width = 200F; using (LabelWidthRestorer.Get(120F)) { EditorGUI.BeginChangeCheck(); mode = (SearchMode)EditorGUI.EnumPopup(r, LC.G("SearchMode"), this.searchMode, GeneralStyles.ToolbarDropDown); } if (EditorGUI.EndChangeCheck() == true) { //Undo.RecordObject(HQ.Settings, "Alter content filter"); this.searchMode = mode; this.cachedResults.Clear(); } r.x += r.width; r.width = 30F; EditorGUI.BeginChangeCheck(); GUI.Toggle(r, this.caseSensitive == CompareOptions.None, this.cs, GeneralStyles.ToolbarToggle); if (EditorGUI.EndChangeCheck() == true) { //Undo.RecordObject(HQ.Settings, "Alter content filter"); if (this.caseSensitive == CompareOptions.IgnoreCase) { this.caseSensitive = CompareOptions.None; } else { this.caseSensitive = CompareOptions.IgnoreCase; } this.cachedResults.Clear(); } r.x += r.width; r.width = 40F; EditorGUI.BeginChangeCheck(); GUI.Toggle(r, this.wholeWord, this.whole, GeneralStyles.ToolbarToggle); if (EditorGUI.EndChangeCheck() == true) { //Undo.RecordObject(HQ.Settings, "Alter content filter"); this.wholeWord = !this.wholeWord; this.cachedResults.Clear(); } r.x += r.width; r.width = 30F; EditorGUI.BeginChangeCheck(); GUI.Toggle(r, this.useRegex, this.regex, GeneralStyles.ToolbarToggle); if (EditorGUI.EndChangeCheck() == true) { //Undo.RecordObject(HQ.Settings, "Alter content filter"); this.useRegex = !this.useRegex; this.cachedResults.Clear(); this.CheckRegex(); } r.x += r.width + 2F; } using (BgColorContentRestorer.Get(string.IsNullOrEmpty(this.regexSyntaxError) == false, Color.red)) { bool unfocused = false; if (Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.DownArrow || Event.current.keyCode == KeyCode.UpArrow) { unfocused = true; } } r.y += 2F; r.width = xMax - r.x - 16F; EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("keyword"); string keyword = EditorGUI.TextField(r, this.keyword, GeneralStyles.ToolbarSearchTextField); if (EditorGUI.EndChangeCheck() == true) { //Undo.RecordObject(HQ.Settings, "Alter content filter"); this.keyword = keyword; this.searchPatterns = null; this.cachedResults.Clear(); this.CheckRegex(); } r.x += r.width; if (unfocused == true) { EditorGUIUtility.editingTextField = false; Event.current.type = EventType.KeyDown; } r.width = 16F; if (GUI.Button(r, GUIContent.none, GeneralStyles.ToolbarSearchCancelButton) == true) { //Undo.RecordObject(HQ.Settings, "Alter content filter"); this.keyword = string.Empty; this.searchPatterns = null; this.cachedResults.Clear(); this.regexSyntaxError = null; GUI.FocusControl(null); } } r.y += r.height; return(r); }
private static void OnGUISettings() { if (HQ.Settings == null) { return; } HierarchyEnhancerSettings settings = HQ.Settings.Get <HierarchyEnhancerSettings>(); EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); using (BgColorContentRestorer.Get(settings.enable == true ? Color.green : Color.red)) { EditorGUILayout.BeginVertical("ButtonLeft"); { EditorGUILayout.BeginHorizontal(); { settings.enable = NGEditorGUILayout.Switch(LC.G("Enable"), settings.enable); } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_EnableDescription"), GeneralStyles.WrapLabel); } EditorGUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck() == true) { if (settings.enable == false) { EditorApplication.hierarchyWindowItemOnGUI -= NGHierarchyEnhancer.DrawOverlay; } else { EditorApplication.hierarchyWindowItemOnGUI += NGHierarchyEnhancer.DrawOverlay; } HQ.InvalidateSettings(); } EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_MarginDescription"), GeneralStyles.WrapLabel); settings.margin = EditorGUILayout.FloatField(LC.G("NGHierarchyEnhancer_Margin"), settings.margin); EditorGUILayout.Space(); EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_HoldModifiersDescription"), GeneralStyles.WrapLabel); settings.holdModifiers = (EventModifiers)EditorGUILayout.MaskField(new GUIContent(LC.G("NGHierarchyEnhancer_HoldModifiers")), (int)settings.holdModifiers, NGHierarchyEnhancer.eventModifierNames); EditorGUILayout.Space(); EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_SelectionHoldModifiersDescription"), GeneralStyles.WrapLabel); settings.selectionHoldModifiers = (EventModifiers)EditorGUILayout.MaskField(new GUIContent(LC.G("NGHierarchyEnhancer_SelectionHoldModifiers")), (int)settings.selectionHoldModifiers, NGHierarchyEnhancer.eventModifierNames); if (EditorGUI.EndChangeCheck() == true) { HQ.InvalidateSettings(); } EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_LayersDescription"), GeneralStyles.WrapLabel); float maxLabelWidth = NGHierarchyEnhancer.width; for (int i = 0; i < HierarchyEnhancerSettings.TotalLayers; i++) { string layerName = LayerMask.LayerToName(i); if (layerName == string.Empty) { layerName = "Layer " + i; } Utility.content.text = layerName; float width = GUI.skin.label.CalcSize(Utility.content).x; if (maxLabelWidth < width + 20F) // Add width for the icon. { maxLabelWidth = width + 20F; } } using (LabelWidthRestorer.Get(maxLabelWidth)) { for (int i = 0; i < HierarchyEnhancerSettings.TotalLayers; i++) { string layerName = LayerMask.LayerToName(i); if (layerName == string.Empty) { layerName = "Layer " + i; } EditorGUILayout.BeginHorizontal(); // (Label + icon) + color picker Rect r = GUILayoutUtility.GetRect(maxLabelWidth + 40F, 16F, GUI.skin.label); Utility.content.text = layerName; float width = GUI.skin.label.CalcSize(Utility.content).x; settings.layers[i] = EditorGUI.ColorField(r, layerName, settings.layers[i]); r.width = maxLabelWidth; EditorGUI.DrawRect(r, settings.layers[i]); if (settings.layersIcon[i] != null) { r.x += width + 2F; // Little space before the icon. r.width = 16F; GUI.DrawTexture(r, settings.layersIcon[i], ScaleMode.ScaleToFit); } settings.layersIcon[i] = EditorGUILayout.ObjectField(settings.layersIcon[i], typeof(Texture2D), false) as Texture2D; EditorGUILayout.EndHorizontal(); } } if (EditorGUI.EndChangeCheck() == true) { HQ.InvalidateSettings(); if (NGHierarchyEnhancer.instance != null) { NGHierarchyEnhancer.instance.Repaint(); } } EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_WidthPerComponentDescription"), GeneralStyles.WrapLabel); settings.widthPerComponent = EditorGUILayout.FloatField(LC.G("NGHierarchyEnhancer_WidthPerComponent"), settings.widthPerComponent); if (EditorGUI.EndChangeCheck() == true) { if (settings.widthPerComponent < -1F) { settings.widthPerComponent = -1F; } HQ.InvalidateSettings(); if (NGHierarchyEnhancer.instance != null) { NGHierarchyEnhancer.instance.Repaint(); } } EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_DrawUnityComponentsDescription"), GeneralStyles.WrapLabel); settings.drawUnityComponents = EditorGUILayout.Toggle(LC.G("NGHierarchyEnhancer_DrawUnityComponents"), settings.drawUnityComponents); if (EditorGUI.EndChangeCheck() == true) { HQ.InvalidateSettings(); if (NGHierarchyEnhancer.instance != null) { NGHierarchyEnhancer.instance.Repaint(); } } EditorGUILayout.Space(); EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_ComponentColorsDescription"), GeneralStyles.WrapLabel); if (reorder == null) { NGHierarchyEnhancer.colors = new List <HierarchyEnhancerSettings.ComponentColor>(settings.componentData); NGHierarchyEnhancer.reorder = new ReorderableList(NGHierarchyEnhancer.colors, typeof(HierarchyEnhancerSettings.ComponentColor), true, false, true, true); NGHierarchyEnhancer.reorder.headerHeight = 0F; NGHierarchyEnhancer.reorder.drawElementCallback += NGHierarchyEnhancer.DrawComponentType; NGHierarchyEnhancer.reorder.onReorderCallback += (r) => NGHierarchyEnhancer.SerializeComponentColors(); NGHierarchyEnhancer.reorder.onRemoveCallback += (r) => { r.list.RemoveAt(r.index); NGHierarchyEnhancer.SerializeComponentColors(); }; NGHierarchyEnhancer.reorder.onAddCallback += (r) => { colors.Add(new HierarchyEnhancerSettings.ComponentColor()); NGHierarchyEnhancer.SerializeComponentColors(); }; } reorder.DoLayoutList(); }
private static void OnGUISettings() { if (HQ.Settings == null) { return; } NavSettings settings = HQ.Settings.Get <NavSettings>(); if (Application.platform != RuntimePlatform.WindowsEditor) { EditorGUILayout.LabelField(LC.G("NGNavSelection_OnlyAvailableOnWindows"), GeneralStyles.WrapLabel); } EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); using (BgColorContentRestorer.Get(settings.enable == true ? Color.green : Color.red)) { EditorGUILayout.BeginVertical("ButtonLeft"); { EditorGUILayout.BeginHorizontal(); { settings.enable = NGEditorGUILayout.Switch(LC.G("Enable"), settings.enable); } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField(LC.G("NGNavSelection_EnableDescription"), GeneralStyles.WrapLabel); } EditorGUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck() == true) { if (settings.enable == false) { Selection.selectionChanged -= NGNavSelectionWindow.UpdateSelection; #if !UNITY_2017_2_OR_NEWER EditorApplication.playmodeStateChanged -= NGNavSelectionWindow.OnPlayStateChanged; #else EditorApplication.playModeStateChanged -= NGNavSelectionWindow.OnPlayStateChanged; #endif } else { Selection.selectionChanged += NGNavSelectionWindow.UpdateSelection; #if !UNITY_2017_2_OR_NEWER EditorApplication.playmodeStateChanged += NGNavSelectionWindow.OnPlayStateChanged; #else EditorApplication.playModeStateChanged += NGNavSelectionWindow.OnPlayStateChanged; #endif } HQ.InvalidateSettings(); } EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); EditorGUILayout.LabelField(LC.G("NGNavSelection_MaxHistoricDescription"), GeneralStyles.WrapLabel); settings.maxHistoric = EditorGUILayout.IntField(LC.G("NGNavSelection_MaxHistoric"), settings.maxHistoric); if (EditorGUI.EndChangeCheck() == true) { settings.maxHistoric = Mathf.Clamp(settings.maxHistoric, 1, NGNavSelectionWindow.MaxHistoric); HQ.InvalidateSettings(); } EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); EditorGUILayout.LabelField(LC.G("NGNavSelection_MaxDisplayHierarchyDescription"), GeneralStyles.WrapLabel); settings.maxDisplayHierarchy = EditorGUILayout.IntField(LC.G("NGNavSelection_MaxDisplayHierarchy"), settings.maxDisplayHierarchy); if (EditorGUI.EndChangeCheck() == true) { if (settings.maxDisplayHierarchy < -1) { settings.maxDisplayHierarchy = -1; } HQ.InvalidateSettings(); } }