public override void OnEditionGUI() { using (LabelWidthRestorer.Get(80F)) { EditorGUI.BeginChangeCheck(); this.maxElements = EditorGUILayout.IntField("Max Element", this.maxElements); if (EditorGUI.EndChangeCheck() == true) { if (this.maxElements < 1) { this.maxElements = 1; } this.hub.Repaint(); } EditorGUI.BeginChangeCheck(); this.maxWidth = EditorGUILayout.FloatField("Max Width", this.maxWidth); if (EditorGUI.EndChangeCheck() == true) { if (this.maxWidth < 30F) { this.maxWidth = 30F; } this.hub.Repaint(); } } }
public override void OnEditionGUI() { using (LabelWidthRestorer.Get(80F)) { EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck(); this.scene = NGEditorGUILayout.OpenFileField("Scene Path", this.scene, "unity", NGEditorGUILayout.FieldButtons.Browse); if (EditorGUI.EndChangeCheck() == true) { int n = this.scene.IndexOf("/Assets/"); if (n != -1) { this.scene = this.scene.Substring(n + 1); // +1 because of the first slash. } } if (this.isSceneValid == false) { EditorGUILayout.HelpBox("Scene does not exist.", MessageType.Warning); } this.alias = EditorGUILayout.TextField("Alias", this.alias); if (EditorGUI.EndChangeCheck() == true) { this.isSceneValid = this.IsValid(this.scene); this.content.text = string.IsNullOrEmpty(this.alias) == true ? this.scene : this.alias; this.content.tooltip = this.scene; } } }
public override void OnEditionGUI() { using (LabelWidthRestorer.Get(60F)) { EditorGUI.BeginChangeCheck(); this.presets1 = EditorGUILayout.FloatField("Preset 1", this.presets1); if (EditorGUI.EndChangeCheck() == true) { this.presets1 = Mathf.Clamp(this.presets1, TimeScaleComponent.MinTime - 1F, TimeScaleComponent.MaxTime); this.presetContent1.tooltip = this.presets1.ToString(); } EditorGUI.BeginChangeCheck(); this.presets2 = EditorGUILayout.FloatField("Preset 2", this.presets2); if (EditorGUI.EndChangeCheck() == true) { this.presets2 = Mathf.Clamp(this.presets2, TimeScaleComponent.MinTime - 1F, TimeScaleComponent.MaxTime); this.presetContent2.tooltip = this.presets2.ToString(); } EditorGUI.BeginChangeCheck(); this.presets3 = EditorGUILayout.FloatField("Preset 3", this.presets3); if (EditorGUI.EndChangeCheck() == true) { this.presets3 = Mathf.Clamp(this.presets3, TimeScaleComponent.MinTime - 1F, TimeScaleComponent.MaxTime); this.presetContent3.tooltip = this.presets3.ToString(); } } }
public void OnGUI(Rect r) { GUILayout.BeginArea(r); { EditorGUILayout.BeginHorizontal(); { using (LabelWidthRestorer.Get(92F)) { this.dataSeparator = EditorGUILayout.TextField(LC.G("DataSeparator"), this.dataSeparator); } if (GUILayout.Button("Tab", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.dataSeparator += "\\t"; } if (GUILayout.Button("CR", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.dataSeparator += "\\r"; } if (GUILayout.Button("LF", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.dataSeparator += "\\n"; } //GUILayout.Space(10F); GUILayout.FlexibleSpace(); using (LabelWidthRestorer.Get(85F)) { this.logSeparator = EditorGUILayout.TextField(LC.G("LogSeparator"), this.logSeparator); } if (GUILayout.Button("Tab", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.logSeparator += "\\t"; } if (GUILayout.Button("CR", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.logSeparator += "\\r"; } if (GUILayout.Button("LF", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.logSeparator += "\\n"; } } EditorGUILayout.EndHorizontal(); } GUILayout.EndArea(); }
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 override void OnGUI(Rect r) { using (LabelWidthRestorer.Get(175F)) { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { GUILayout.Label("General"); } EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); this.window.Hierarchy.displayNonSuppported = EditorGUILayout.Toggle("Display Non-Suppported", this.window.Hierarchy.displayNonSuppported); GUILayout.Label("Only Texture2D & Mesh are supported, others will be discarded.", GeneralStyles.WrapLabel); TooltipHelper.HelpBox("If you need to implement your own,\nlook for the C# interface IObjectImporter in NGTools.NGRemoteScene.", MessageType.Info); this.window.Hierarchy.overridePrefab = EditorGUILayout.Toggle("Override Prefab", this.window.Hierarchy.overridePrefab); GUILayout.Label("If a prefab exists at the location, it will be overridden. Otherwise a copy nearby will be created.", GeneralStyles.WrapLabel); if (EditorGUI.EndChangeCheck() == true) { this.window.Repaint(); } GUILayout.Space(5F); EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { GUILayout.Label("Auto Mode Settings"); } EditorGUILayout.EndHorizontal(); TooltipHelper.HelpBox("The following settings apply when Auto mode is selected.", MessageType.Info); EditorGUI.BeginChangeCheck(); this.window.Hierarchy.specificSharedSubFolder = EditorGUILayout.TextField("Specific Import Folder", this.window.Hierarchy.specificSharedSubFolder); GUILayout.Label("Set a path to force import of each asset into the root of the given folder, leave it blank to import near prefab's location.", GeneralStyles.WrapLabel); GUILayout.Space(5F); //this.window.hierarchy.rawCopyAssetsToSubFolder = EditorGUILayout.Toggle("Import Asset Into Sub-Folder", this.window.hierarchy.rawCopyAssetsToSubFolder); //GUILayout.Label("Import every assets into a sub-folder using its prefab name.", GeneralStyles.WrapLabel); //this.window.hierarchy.prefixAsset = EditorGUILayout.Toggle("Prefix Asset", this.window.hierarchy.prefixAsset); //GUILayout.Label("Prefix each asset with its prefab name.", GeneralStyles.WrapLabel); //if (EditorGUI.EndChangeCheck() == true) //{ // for (int i = 0; i < this.window.hierarchy.ImportingAssetsParams.Count; i++) // this.window.hierarchy.ImportingAssetsParams[i].autoPath = null; // this.window.Repaint(); //} } TooltipHelper.PostOnGUI(); }
public override void OnEditionGUI() { using (LabelWidthRestorer.Get(60F)) { EditorGUI.BeginChangeCheck(); this.asset = EditorGUILayout.ObjectField("Asset", this.asset, typeof(Object), false); this.image = EditorGUILayout.ObjectField("Image", this.image, typeof(Texture), false) as Texture; this.text = EditorGUILayout.TextField("Text", this.text); if (EditorGUI.EndChangeCheck() == true) { this.content.text = this.text; this.content.tooltip = this.asset != null ? this.asset.name : string.Empty; } } }
public override void OnGUI() { using (LabelWidthRestorer.Get(70F)) { EditorGUI.BeginChangeCheck(); using (LabelWidthRestorer.Get(40F)) { EditorGUILayout.BeginHorizontal(); { this.mode = (Mode)EditorGUILayout.EnumPopup("Mode", this.mode); if (this.mode == Mode.Insert) { using (LabelWidthRestorer.Get(25F)) { this.position = EditorGUILayout.IntField("At", this.position); } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { this.start = EditorGUILayout.IntField("Start", this.start); this.inc = EditorGUILayout.IntField("Inc", this.inc); this.pad = EditorGUILayout.IntField("Pad", this.pad); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); this.baseNumber = (Base)EditorGUILayout.EnumPopup("Base", this.baseNumber); using (LabelWidthRestorer.Get(110F)) { this.romanCase = (RomanNumeral)EditorGUILayout.EnumPopup("Roman Numerals", this.romanCase); } EditorGUILayout.EndHorizontal(); } if (EditorGUI.EndChangeCheck() == true) { this.enable = true; this.renamer.Invalidate(); } } }
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() { using (LabelWidthRestorer.Get(this.position.width)) { EditorGUILayout.PrefixLabel("Submit package for approval?"); } this.comments = EditorGUILayout.TextArea(this.comments, GUILayoutOptionPool.ExpandHeightTrue); this.autoPublish = EditorGUILayout.Toggle("Auto Publish", this.autoPublish); using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Submit") == true) { onPublish(this.autoPublish, this.comments); this.Close(); } } }
public override void OnGUI() { using (LabelWidthRestorer.Get(60F)) { EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); { this.firstN = EditorGUILayout.IntField("First N", this.firstN); if (this.firstN < 0) { this.firstN = 0; } this.lastN = EditorGUILayout.IntField("Last N", this.lastN); if (this.lastN < 0) { this.lastN = 0; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { this.startPosition = EditorGUILayout.IntField("From", this.startPosition); if (this.startPosition < 0) { this.startPosition = 0; } this.endPosition = EditorGUILayout.IntField("To", this.endPosition); if (this.endPosition < this.startPosition) { this.endPosition = this.startPosition; } } EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck() == true) { this.enable = true; this.renamer.Invalidate(); } } }
public override void OnGUI() { using (LabelWidthRestorer.Get(70F)) { EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); { this.@operator = (Operation)EditorGUILayout.EnumPopup(this.@operator); if (this.@operator == Operation.Add) { this.extension = EditorGUILayout.TextField(this.extension); } } EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck() == true) { this.enable = true; this.renamer.Invalidate(); } } }
public override void OnGUIModule(Rect r, NGRemoteHierarchyWindow hierarchy) { using (LabelWidthRestorer.Get(110F)) { r.height = Constants.SingleLineHeight; EditorGUI.BeginChangeCheck(); this.useJPG = EditorGUI.Toggle(r, "Use JPG", this.useJPG); if (EditorGUI.EndChangeCheck() == true) { NGEditorPrefs.SetBool(ScreenshotModuleEditor.UseJPGKeyPref, this.useJPG, true); if (hierarchy.IsClientConnected() == true) { hierarchy.Client.AddPacket(new ClientModuleSetUseJPGPacket(this.useJPG)); } } r.y += r.height + 2F; EditorGUI.BeginChangeCheck(); this.useCompression = EditorGUI.Toggle(r, "Use Compression", this.useCompression); if (EditorGUI.EndChangeCheck() == true) { NGEditorPrefs.SetBool(ScreenshotModuleEditor.UseCompressionKeyPref, this.useCompression, true); if (hierarchy.IsClientConnected() == true) { hierarchy.Client.AddPacket(new ClientModuleSetUseCompressionPacket(this.useCompression)); } } r.y += r.height + 2F; EditorGUI.BeginChangeCheck(); r.width = 210F; this.scaleMode = (ScaleMode)NGEditorGUILayout.EnumPopup(r, "Scale Mode", this.scaleMode); if (EditorGUI.EndChangeCheck() == true) { NGEditorPrefs.SetInt(ScreenshotModuleEditor.ScaleModeKeyPref, (int)this.scaleMode, true); } } }
public override void OnEditionGUI() { using (LabelWidthRestorer.Get(100F)) { if (GUILayout.Button("Pick") == true) { GenericMenu menu = new GenericMenu(); string[] menuItems = Utility.GetAllMenuItems(); for (int i = 0; i < menuItems.Length; i++) { menu.AddItem(new GUIContent(menuItems[i]), false, this.PickMenuItem, menuItems[i]); } menu.ShowAsContext(); } this.menuItem = EditorGUILayout.TextField("Menu Item Path", this.menuItem); this.image = EditorGUILayout.ObjectField("Image", this.image, typeof(Texture), false) as Texture; this.alias = EditorGUILayout.TextField("Alias", this.alias); } }
public override void OnGUI() { EditorGUI.BeginChangeCheck(); using (LabelWidthRestorer.Get(90F)) { this.pattern = EditorGUILayout.TextField("Search For", this.pattern); if (EditorGUI.EndChangeCheck() == true) { try { this.regexError = null; new Regex(this.pattern); } catch (Exception ex) { this.regexError = ex.Message; } this.enable = true; this.renamer.Invalidate(); } if (string.IsNullOrEmpty(this.regexError) == false) { EditorGUILayout.HelpBox(this.regexError, MessageType.Warning); } EditorGUI.BeginChangeCheck(); this.replace = EditorGUILayout.TextField("Replace With", this.replace); this.regex = EditorGUILayout.Toggle("Regex", this.regex); this.caseSensitive = EditorGUILayout.Toggle("Case Sensitive", this.caseSensitive); } if (EditorGUI.EndChangeCheck() == true) { this.enable = true; this.renamer.Invalidate(); } }
public override void OnGUI() { using (LabelWidthRestorer.Get(70F)) { EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); { this.text = EditorGUILayout.TextField("Insert", this.text); using (LabelWidthRestorer.Get(25F)) { this.position = EditorGUILayout.IntField("At", this.position); } } EditorGUILayout.EndHorizontal(); this.prefix = EditorGUILayout.TextField("Prefix", this.prefix); this.suffix = EditorGUILayout.TextField("Suffix", this.suffix); if (EditorGUI.EndChangeCheck() == true) { this.enable = true; this.renamer.Invalidate(); } } }
public override void Draw(Rect r, DataDrawer data) { if (this.animX == null) { this.animX = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); this.animY = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); this.animZ = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); } Vector3 vector = (Vector3)data.Value; float labelWidth; float controlWidth; Utility.CalculSubFieldsWidth(r.width, 60F, 3, out labelWidth, out controlWidth); r.width = labelWidth; EditorGUI.LabelField(r, data.Name); r.x += r.width; using (IndentLevelRestorer.Get(0)) using (LabelWidthRestorer.Get(12F)) { r.width = controlWidth; string path = data.GetPath(); if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + 'x') != NotificationPath.None) { this.dragX.NewValue(vector.x); this.animX.Start(); } using (this.animX.Restorer(0F, .8F + this.animX.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single v = EditorGUI.FloatField(r, "X", this.dragX.Get(vector.x)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + 'x', v, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + 'x', typeof(Single), this.dragX.Get(vector.x), v); this.dragX.Set(v); } this.dragX.Draw(r); r.x += r.width; } if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + 'y') != NotificationPath.None) { this.dragY.NewValue(vector.y); this.animY.Start(); } using (this.animY.Restorer(0F, .8F + this.animY.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single v = EditorGUI.FloatField(r, "Y", this.dragY.Get(vector.y)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + 'y', v, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + 'y', typeof(Single), this.dragY.Get(vector.y), v); this.dragY.Set(v); } this.dragY.Draw(r); r.x += r.width; } if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + 'z') != NotificationPath.None) { this.dragZ.NewValue(vector.z); this.animZ.Start(); } using (this.animZ.Restorer(0F, .8F + this.animZ.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single v = EditorGUI.FloatField(r, "Z", this.dragZ.Get(vector.z)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + 'z', v, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + 'z', typeof(Single), this.dragZ.Get(vector.z), v); this.dragZ.Set(v); } this.dragZ.Draw(r); } } }
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 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(); }
public override void OnGUI(Rect r) { Rect bodyRect = r; Rect viewRect = r; float height = r.height; List <NGRemoteHierarchyWindow.UserAsset> assets = this.window.hierarchy.GetUserAssets(typeof(Sprite)); if (this.window.hierarchy.IsChannelBlocked(typeof(Sprite).GetHashCode()) == true) { bodyRect.height = Constants.SingleLineHeight; GUI.Label(r, GeneralStyles.StatusWheel); bodyRect.xMin += bodyRect.height; GUI.Label(bodyRect, "Loading Sprite"); bodyRect.xMin -= bodyRect.height; bodyRect.y += bodyRect.height; bodyRect.height = height - bodyRect.height; this.window.Repaint(); } if (assets != null && assets.Count > 0) { Utility.content.text = "User Sprite:"; Vector2 titleSize = GeneralStyles.Title1.CalcSize(Utility.content); float maxWidth = titleSize.x; GUI.Label(bodyRect, Utility.content.text, GeneralStyles.Title1); for (int i = 0; i < assets.Count; i++) { Utility.content.text = assets[i].name; float w = GeneralStyles.ToolbarButton.CalcSize(Utility.content).x; if (maxWidth < w) { maxWidth = w; } } viewRect.y = 0F; viewRect.width = maxWidth; viewRect.height = assets.Count * GeneralStyles.ToolbarButton.CalcSize(Utility.content).y; bodyRect.x += maxWidth; bodyRect.width = 1F; EditorGUI.DrawRect(bodyRect, Color.black); bodyRect.width = maxWidth; bodyRect.x -= maxWidth; bodyRect.yMin += titleSize.y; NGRemoteHierarchyWindow.UserAsset hoverData = null; this.scrollPosition = GUI.BeginScrollView(bodyRect, this.scrollPosition, viewRect); { bodyRect.x = 0F; bodyRect.y = 0F; bodyRect.height = GeneralStyles.ToolbarButton.CalcSize(Utility.content).y; for (int i = 0; i < assets.Count; i++) { Color restore = GeneralStyles.ToolbarButton.normal.textColor; if (this.window.selectedInstanceID == assets[i].instanceID) { GeneralStyles.ToolbarButton.normal.textColor = UserSpriteTab.FocusColor; } else if (this.window.initialInstanceID == assets[i].instanceID) { GeneralStyles.ToolbarButton.normal.textColor = UserSpriteTab.InitialColor; } Utility.content.text = assets[i].name; if (GUI.Button(bodyRect, Utility.content, GeneralStyles.ToolbarButton) == true) { if (this.window.selectedInstanceID == assets[i].instanceID) { this.window.Close(); } else { this.window.selectedInstanceID = assets[i].instanceID; ByteBuffer buffer = Utility.GetBBuffer(); this.window.typeHandler.Serialize(buffer, typeof(Sprite), new UnityObject(typeof(Sprite), assets[i].instanceID)); this.window.hierarchy.AddPacket(this.window.packetGenerator(this.window.valuePath, Utility.ReturnBBuffer(buffer))); } } GeneralStyles.ToolbarButton.normal.textColor = restore; if (bodyRect.Contains(Event.current.mousePosition) == true) { hoverData = assets[i]; } bodyRect.y += bodyRect.height; } } GUI.EndScrollView(); r.xMin += maxWidth + 2F; if (this.hoverData != hoverData) { this.hoverData = hoverData; if (this.hoverData != null) { this.cachedHoverData = string.Join("\n", this.hoverData.data); } } } using (LabelWidthRestorer.Get(80F)) { bodyRect = r; bodyRect.height = Constants.SingleLineHeight; this.textureName = EditorGUI.TextField(bodyRect, "Name", this.textureName); bodyRect.y += bodyRect.height + UserSpriteTab.GUISpacing; EditorGUI.BeginChangeCheck(); bodyRect.height = 50F; this.sprite = EditorGUI.ObjectField(bodyRect, "Sprite", this.sprite, typeof(Sprite), false) as Sprite; bodyRect.y += bodyRect.height + UserSpriteTab.GUISpacing; if (EditorGUI.EndChangeCheck() == true) { if (this.sprite != null && (string.IsNullOrEmpty(this.textureName) == true || this.textureName.EndsWith(UserSpriteTab.DefaultSuffix) == true)) { this.textureName = this.sprite.name + UserSpriteTab.DefaultSuffix; } } } if (this.sprite != null) { bodyRect.height = height - (Constants.SingleLineHeight + UserSpriteTab.GUISpacing + 50F + UserSpriteTab.GUISpacing) - Constants.SingleLineHeight - UserSpriteTab.BottomHeight; if (bodyRect.height < 100F) { bodyRect.height = 100F; } EditorGUI.DrawTextureTransparent(bodyRect, this.sprite.texture, ScaleMode.ScaleToFit); bodyRect.y += bodyRect.height; bodyRect.height = Constants.SingleLineHeight; GUI.Label(bodyRect, "W: " + this.sprite.texture.width + " H: " + this.sprite.texture.height + " Format: " + this.sprite.texture.format + " PixelsPerUnit: " + this.sprite.pixelsPerUnit); bodyRect.y += bodyRect.height; try { bodyRect.height = UserSpriteTab.BottomHeight; this.sprite.texture.GetPixel(0, 0); if (GUI.Button(bodyRect, "Send") == true) { this.window.hierarchy.SendUserSprite(this.textureName, this.sprite.texture.EncodeToPNG(), this.sprite.rect, this.sprite.pivot, this.sprite.pixelsPerUnit, asset => this.window.Repaint()); } } catch (UnityException) { EditorGUI.HelpBox(bodyRect, "Sprite must be readable.", MessageType.Error); } } if (this.hoverData != null) { Sprite sprite = EditorUtility.InstanceIDToObject(this.hoverData.instanceID) as Sprite; if (sprite != null) { if (sprite.texture.width >= sprite.texture.height) { r.width = 100F; r.height = 100F * sprite.texture.height / sprite.texture.width; } else { r.width = 100F * sprite.texture.width / sprite.texture.height; r.height = 100F; } EditorGUI.DrawTextureTransparent(r, sprite.texture, ScaleMode.ScaleToFit); } else { r.width = 100F; r.height = 32F; EditorGUI.DrawRect(r, UserSpriteTab.HoverBackgroundColor); EditorGUI.HelpBox(r, "Preview not available.", MessageType.Warning); } r.y += r.height; Utility.content.text = this.cachedHoverData; Vector2 size = GUI.skin.label.CalcSize(Utility.content); r.width = size.x; r.height = size.y; EditorGUI.DrawRect(r, UserSpriteTab.HoverBackgroundColor); GUI.Label(r, Utility.content.text); } if (Event.current.type == EventType.MouseMove) { this.window.Repaint(); } }
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; } 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(); } }
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"); }
public override void OnEditionGUI() { using (LabelWidthRestorer.Get(100F)) { if (this.methodInfo != null) { EditorGUILayout.LabelField("Static Method", this.methodInfo.DeclaringType.Name + ":" + this.methodInfo.Name + "()"); this.alias = EditorGUILayout.TextField("Alias", this.alias); Rect r2 = GUILayoutUtility.GetLastRect(); r2.y += r2.height + 3F; r2.height = 1F; EditorGUI.DrawRect(r2, Color.gray); GUILayout.Space(5F); } Rect r = GUILayoutUtility.GetRect(0F, Constants.SingleLineHeight, GUI.skin.textField); float width = r.width; EditorGUI.BeginChangeCheck(); this.type = EditorGUI.TextField(r, "Search Type", this.type); if (EditorGUI.EndChangeCheck() == true) { this.RefreshTypes(); return; } this.filterTypesScrollPosition = EditorGUILayout.BeginScrollView(this.filterTypesScrollPosition, GUILayoutOptionPool.Height(Mathf.Min(this.matchingTypes.Count * 18F + 10F, 160F)), GUILayoutOptionPool.ExpandHeightFalse); { for (int i = 0; i < this.matchingTypes.Count; i++) { if (GUILayout.Button(this.matchingTypes[i].Name) == true) { this.selectedType = this.matchingTypes[i]; this.availableStaticMethods = this.selectedType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); return; } } } EditorGUILayout.EndScrollView(); if (this.availableStaticMethods != null) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Selected Type", this.selectedType.FullName); if (this.availableStaticMethods.Length == 0) { GUILayout.Label("No static method found."); } else { this.methodsScrollPosition = EditorGUILayout.BeginScrollView(this.methodsScrollPosition, GUILayoutOptionPool.Height(Mathf.Min(this.availableStaticMethods.Length * 18F + 10F, 160F)), GUILayoutOptionPool.ExpandHeightFalse); { for (int i = 0; i < this.availableStaticMethods.Length; i++) { if (GUILayout.Button(this.availableStaticMethods[i].Name) == true) { this.methodInfo = this.availableStaticMethods[i]; this.typeString = this.selectedType.AssemblyQualifiedName; this.methodName = this.methodInfo.Name; return; } } } EditorGUILayout.EndScrollView(); } } } }
protected virtual void OnGUI() { if (this.hub == null || this.hub.Initialized == false) { return; } if (this.list == null) { this.list = new ReorderableList(this.hub.components, typeof(HubComponent), true, false, true, true); this.list.headerHeight = 24F; this.list.drawHeaderCallback = (r) => GUI.Label(r, "Components", GeneralStyles.Title1); this.list.showDefaultBackground = false; this.list.drawElementCallback = this.DrawComponent; this.list.onAddCallback = this.OpenAddComponentWizard; this.list.onRemoveCallback = (l) => { l.list.RemoveAt(l.index); this.hub.SaveComponents(); }; this.list.onReorderCallback = (l) => this.hub.SaveComponents(); this.list.onChangedCallback = (l) => this.hub.Repaint(); } MethodInfo[] droppableComponentsMethods = this.hub.DroppableComponents; if (droppableComponentsMethods.Length > 0 && DragAndDrop.objectReferences.Length > 0) { for (int i = 0; i < droppableComponentsMethods.Length; i++) { if ((bool)droppableComponentsMethods[i].Invoke(null, null) == true) { Rect r = GUILayoutUtility.GetRect(GUI.skin.label.CalcSize(new GUIContent(droppableComponentsMethods[i].DeclaringType.Name)).x, this.hub.height, GUI.skin.label); if (Event.current.type == EventType.Repaint) { Utility.DropZone(r, Utility.NicifyVariableName(droppableComponentsMethods[i].DeclaringType.Name)); this.Repaint(); } else if (Event.current.type == EventType.DragUpdated && r.Contains(Event.current.mousePosition) == true) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; } else if (Event.current.type == EventType.DragPerform && r.Contains(Event.current.mousePosition) == true) { DragAndDrop.AcceptDrag(); HubComponent component = Activator.CreateInstance(droppableComponentsMethods[i].DeclaringType) as HubComponent; if (component != null) { component.InitDrop(this.hub); this.hub.components.Add(component); this.hub.SaveComponents(); } DragAndDrop.PrepareStartDrag(); Event.current.Use(); } } } } Rect r2 = this.position; r2.x = 0F; if (this.hub.DockedAsMenu == false) { r2.y = 24F; using (LabelWidthRestorer.Get(50F)) { EditorGUI.BeginChangeCheck(); this.hub.height = EditorGUILayout.FloatField("Height", this.hub.height); if (EditorGUI.EndChangeCheck() == true) { this.hub.Repaint(); } } } else { r2.y = 0F; } EditorGUI.BeginChangeCheck(); this.hub.backgroundColor = EditorGUILayout.ColorField("Background Color", this.hub.backgroundColor); if (EditorGUI.EndChangeCheck() == true) { this.hub.Repaint(); } this.headerRect = GUILayoutUtility.GetLastRect(); this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition); { this.list.DoLayoutList(); } EditorGUILayout.EndScrollView(); }
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() { EditorGUILayout.HelpBox("Meta assemblies are libraries (or DLL) converted, compacted & saved to be reused offline.\nAllowing to verify compatibility with a Unity version without installing it.", MessageType.Info); if (this.metaLabel == null || this.metaLabel.Length != this.meta.Length) { this.metaLabel = new string[this.meta.Length]; for (int i = 0, max = this.metaLabel.Length; i < max; ++i) { this.metaLabel[i] = (i + 1) + " - " + Path.GetFileNameWithoutExtension(this.meta[i].AssemblyPath); } } using (LabelWidthRestorer.Get(100F)) { EditorGUI.BeginChangeCheck(); this.selectedMeta = EditorGUILayout.Popup("Meta Assembly", this.selectedMeta, this.metaLabel); if (EditorGUI.EndChangeCheck() == true) { this.typesLabel = null; } } if (this.selectedMeta >= 0 && this.selectedMeta < this.meta.Length) { using (var scroll = new EditorGUILayout.ScrollViewScope(this.scrollPosition)) { this.scrollPosition = scroll.scrollPosition; AssemblyMeta assemblyMeta = this.meta[this.selectedMeta]; using (LabelWidthRestorer.Get(60F)) { EditorGUILayout.LabelField("Location", assemblyMeta.AssemblyPath); using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar)) { this.displayFriends = EditorGUILayout.Foldout(this.displayFriends, "Friends (" + assemblyMeta.FriendAssemblies.Length + " assemblies)", true); } } if (this.displayFriends == true) { ++EditorGUI.indentLevel; for (int i = 0, max = assemblyMeta.FriendAssemblies.Length; i < max; ++i) { EditorGUILayout.LabelField(assemblyMeta.FriendAssemblies[i]); } --EditorGUI.indentLevel; } GUILayout.Space(10F); using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar)) { EditorGUILayout.LabelField(this.displayNamespaces == true ? "Namespaces" : "Types (" + assemblyMeta.Types.Length + ")"); GUILayout.FlexibleSpace(); if (GUILayout.Button(this.displayNamespaces == true ? "Display Type" : "Display Namespace", EditorStyles.toolbarButton) == true) { this.displayNamespaces = !this.displayNamespaces; } } if (this.displayNamespaces == true) { for (int i = 0, max = assemblyMeta.GlobalNamespace.Namespaces.Count; i < max; ++i) { this.DrawNamespace(assemblyMeta.GlobalNamespace.Namespaces[i]); } } else { if (this.typesLabel == null || this.typesLabel.Length != assemblyMeta.Types.Length) { this.typesLabel = new string[assemblyMeta.Types.Length]; StringBuilder buffer = Utility.GetBuffer(); for (int i = 0, max = assemblyMeta.Types.Length; i < max; ++i) { TypeMeta typeMeta = assemblyMeta.Types[i]; buffer.Length = 0; buffer.Append(typeMeta.FullName); //buffer.Append(" ("); if (typeMeta.Events.Length > 0) { buffer.Append(" - "); buffer.Append(typeMeta.Events.Length); buffer.Append(" events"); } if (typeMeta.Fields.Length > 0) { buffer.Append(" - "); buffer.Append(typeMeta.Fields.Length); buffer.Append(" fields"); } if (typeMeta.Properties.Length > 0) { buffer.Append(" - "); buffer.Append(typeMeta.Properties.Length); buffer.Append(" properties"); } if (typeMeta.Methods.Length > 0) { buffer.Append(" - "); buffer.Append(typeMeta.Methods.Length); buffer.Append(" methods"); } //buffer.Append(')'); this.typesLabel[i] = buffer.ToString(); } Utility.RestoreBuffer(buffer); } Event eventCurrent = Event.current; if (eventCurrent.type == EventType.MouseMove) { this.Repaint(); } for (int i = 0, max = assemblyMeta.Types.Length; i < max; ++i) { EditorGUILayout.LabelField(this.typesLabel[i]); Rect r = GUILayoutUtility.GetLastRect(); if (r.Contains(eventCurrent.mousePosition) == true) { r.xMin = r.xMax - 100F; if (GUI.Button(r, "Inspect") == true) { Utility.OpenWindow <TypeMetaWindow>(true, TypeMetaWindow.Title, true, null, w => w.typeMeta = assemblyMeta.Types[i]); return; } } } } } } }
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(); } } } } }
protected virtual void OnGUI() { bool hasDiff = false; this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition); { using (LabelWidthRestorer.Get(170F)) { foreach (HQ.ToolAssemblyInfo tool in HQ.EachTool) { int i = this.names.IndexOf(tool.name); if (i == -1) { continue; } if (this.versions[i] != tool.version) { hasDiff = true; } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel(this.names[i]); GUILayout.Label(tool.version); this.versions[i] = EditorGUILayout.TextField(this.versions[i]); if (this.paths[i] != string.Empty) { if (GUILayout.Button("Open") == true) { EditorUtility.OpenWithDefaultApp(this.paths[i]); } } } EditorGUILayout.EndHorizontal(); } } } GUILayout.EndScrollView(); GUI.enabled = hasDiff; if (GUILayout.Button("Update") == true) { StringBuilder buffer = Utility.GetBuffer(); foreach (HQ.ToolAssemblyInfo tool in HQ.EachTool) { int i = this.names.IndexOf(tool.name); if (i == -1 || this.versions[i] == tool.version) { continue; } if (this.paths[i] != string.Empty) { string[] lines = File.ReadAllLines(this.paths[i]); for (int j = 0; j < lines.Length; j++) { if (lines[j].Contains("public const string Version") == true) { lines[j] = lines[j].Replace(tool.version, this.versions[i]); break; } } for (int j = 0; j < lines.Length; j++) { if (j > 0) { buffer.AppendLine(); } buffer.Append(lines[j]); } File.WriteAllText(this.paths[i], buffer.ToString()); buffer.Length = 0; InternalNGDebug.Log("Updated \"" + this.paths[i] + "\" with version \"" + this.versions[i] + "\"."); } } Utility.RestoreBuffer(buffer); } }
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); }