Make a selectable label field. (Useful for showing read-only info that can be copy-pasted.)
public void OnGUI() { var evt = Event.current; var mainLayoutWidth = position.width - Styles.mainLayout.margin.horizontal; using (new GUILayout.VerticalScope(Styles.mainLayout)) { GUILayout.Label(Styles.HeaderLogo, Styles.HeaderLayout); using (new GUILayout.HorizontalScope(Styles.versionLayout)) { ListenForSecretCodes(); string extensionVersion = FormatExtensionVersionString(); m_ShowDetailedVersion |= evt.alt; if (m_ShowDetailedVersion) { int t = InternalEditorUtility.GetUnityVersionDate(); DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0); string branch = InternalEditorUtility.GetUnityBuildBranch(); EditorGUILayout.SelectableLabel( string.Format("{0}{1}\nRevision: {2} {3}\nBuilt: {4:r}", InternalEditorUtility.GetUnityDisplayVersionVerbose(), extensionVersion, branch, InternalEditorUtility.GetUnityBuildHash(), dt.AddSeconds(t)), Styles.versionStyle, GUILayout.MaxWidth(mainLayoutWidth), GUILayout.Height(38f)); } else { GUILayout.Label(string.Format("{0}{1}", InternalEditorUtility.GetUnityDisplayVersion(), extensionVersion), Styles.versionStyle); } if (evt.type == EventType.ValidateCommand) { return; } } using (new GUILayout.HorizontalScope(Styles.creditsLayout)) { float chunkOffset = m_TextYPos; Rect scrollAreaRect = GUILayoutUtility.GetRect(0, mainLayoutWidth, 75f, position.height, GUILayout.ExpandHeight(true)); GUI.BeginGroup(scrollAreaRect); foreach (string nameChunk in AboutWindowNames.Names(null, true)) { chunkOffset = DoCreditsNameChunk(nameChunk, mainLayoutWidth, chunkOffset); } chunkOffset = DoCreditsNameChunk(kSpecialThanksNames, mainLayoutWidth, chunkOffset); m_TotalCreditsHeight = chunkOffset - m_TextYPos; GUI.EndGroup(); HandleScrollEvents(evt, scrollAreaRect); } using (new GUILayout.HorizontalScope(Styles.poweredLayout)) { var poweredBySectionMaxWidth = (mainLayoutWidth - Styles.poweredSectionLayout.margin.horizontal * 2) / 2f; using (new GUILayout.VerticalScope(Styles.poweredSectionLayout, GUILayout.MaxWidth(poweredBySectionMaxWidth))) { GUILayout.Label("Scripting powered by The Mono Project.\n\u00A9 2011 Novell, Inc.", Styles.aboutWindowLicenseLabel); GUILayout.FlexibleSpace(); GUILayout.Label(Styles.MonoLogo, Styles.MonoLogoLayout); GUILayout.FlexibleSpace(); if (!InternalEditorUtility.IsUnityBeta()) { var specialThanksRect = GUILayoutUtility.GetRect(Styles.thanksContent, Styles.thanksStyle); if (GUI.Button(specialThanksRect, Styles.thanksContent, Styles.thanksStyle)) { Process.Start(Styles.thanksUri.AbsoluteUri); } EditorGUIUtility.AddCursorRect(specialThanksRect, MouseCursor.Link); } GUILayout.Label(InternalEditorUtility.GetUnityCopyright().Replace("(c)", "\u00A9"), Styles.aboutWindowLicenseLabel); } GUILayout.FlexibleSpace(); using (new GUILayout.VerticalScope(Styles.poweredSectionLayout, GUILayout.MaxWidth(poweredBySectionMaxWidth))) { GUILayout.Label("Physics powered by PhysX.\n\u00A9 2019 NVIDIA Corporation.", Styles.aboutWindowLicenseLabel); GUILayout.FlexibleSpace(); GUILayout.Label(Styles.AgeiaLogo, Styles.AgeiaLogoLayout); GUILayout.FlexibleSpace(); GUILayout.Label(InternalEditorUtility.GetLicenseInfo().Replace("(c)", "\u00A9"), Styles.aboutWindowLicenseLabel); } } } }
public override void OnInspectorGUI() { serializedObject.Update(); using (new EditorGUI.DisabledScope(false)) { var isManagedPlugin = importers.All(x => x.dllType == DllType.ManagedNET35 || x.dllType == DllType.ManagedNET40); if (isManagedPlugin) { ShowReferenceOptions(); GUILayout.Space(10f); } GUILayout.Label("Select platforms for plugin", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); ShowGeneralOptions(); EditorGUILayout.EndVertical(); GUILayout.Space(10f); if (IsEditingPlatformSettingsSupported()) { ShowPlatformSettings(); } if (isManagedPlugin) { GUILayout.Label(defineConstraints, EditorStyles.boldLabel); m_DefineConstraints.DoLayoutList(); } if (importers.All(imp => imp.isNativePlugin)) { GUILayout.Space(10f); GUILayout.Label(loadSettings, EditorStyles.boldLabel); ShowLoadSettings(); } } serializedObject.ApplyModifiedProperties(); ApplyRevertGUI(); // Don't output additional information if we have multiple plugins selected if (targets.Length > 1) { return; } GUILayout.Label("Information", EditorStyles.boldLabel); m_InformationScrollPosition = EditorGUILayout.BeginVerticalScrollView(m_InformationScrollPosition); foreach (var prop in m_PluginInformation) { GUILayout.BeginHorizontal(); GUILayout.Label(prop.Key, GUILayout.Width(85)); EditorGUILayout.SelectableLabel(prop.Value, GUILayout.Height(EditorGUI.kSingleLineHeight)); GUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); // Warning for Case 648027 // Once Mono loads a native plugin, it never releases a handle, thus plugin is never unloaded. if (importer.isNativePlugin) { EditorGUILayout.HelpBox("Once a native plugin is loaded from script, it's never unloaded. If you deselect a native plugin and it's already loaded, please restart Unity.", MessageType.Warning); } if (EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy && importer.dllType == DllType.ManagedNET40 && m_CompatibleWithEditor == Compatibility.Compatible) { EditorGUILayout.HelpBox("Plugin targets .NET 4.x and is marked as compatible with Editor, Editor can only use assemblies targeting .NET 3.5 or lower, please unselect Editor as compatible platform.", MessageType.Error); } }
internal void OnGUI() { Event e = Event.current; LoadIcons(); if (!m_HasUpdatedGuiStyles) { m_LineHeight = Mathf.RoundToInt(Constants.ErrorStyle.lineHeight); m_BorderHeight = Constants.ErrorStyle.border.top + Constants.ErrorStyle.border.bottom; UpdateListView(); } GUILayout.BeginHorizontal(Constants.Toolbar); if (GUILayout.Button(Constants.ClearLabel, Constants.MiniButton)) { LogEntries.Clear(); GUIUtility.keyboardControl = 0; } int currCount = LogEntries.GetCount(); if (m_ListView.totalRows != currCount && m_ListView.totalRows > 0) { // scroll bar was at the bottom? if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight) { m_ListView.scrollPos.y = currCount * RowHeight - ms_LVHeight; } } EditorGUILayout.Space(); bool wasCollapsed = HasFlag(ConsoleFlags.Collapse); SetFlag(ConsoleFlags.Collapse, GUILayout.Toggle(wasCollapsed, Constants.CollapseLabel, Constants.MiniButton)); bool collapsedChanged = (wasCollapsed != HasFlag(ConsoleFlags.Collapse)); if (collapsedChanged) { // unselect if collapsed flag changed m_ListView.row = -1; // scroll to bottom m_ListView.scrollPos.y = LogEntries.GetCount() * RowHeight; } SetFlag(ConsoleFlags.ClearOnPlay, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnPlay), Constants.ClearOnPlayLabel, Constants.MiniButton)); SetFlag(ConsoleFlags.ClearOnBuild, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnBuild), Constants.ClearOnBuildLabel, Constants.MiniButton)); SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPauseLabel, Constants.MiniButton)); ConnectionGUILayout.AttachToPlayerDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown); EditorGUILayout.Space(); if (m_DevBuild) { GUILayout.FlexibleSpace(); SetFlag(ConsoleFlags.StopForAssert, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForAssert), Constants.StopForAssertLabel, Constants.MiniButton)); SetFlag(ConsoleFlags.StopForError, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForError), Constants.StopForErrorLabel, Constants.MiniButton)); } GUILayout.FlexibleSpace(); // Search bar GUILayout.Space(4f); SearchField(e); GUILayout.Space(4f); // Flags int errorCount = 0, warningCount = 0, logCount = 0; LogEntries.GetCountsByType(ref errorCount, ref warningCount, ref logCount); EditorGUI.BeginChangeCheck(); bool setLogFlag = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelLog), new GUIContent((logCount <= 999 ? logCount.ToString() : "999+"), logCount > 0 ? iconInfoSmall : iconInfoMono), Constants.MiniButton); bool setWarningFlag = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelWarning), new GUIContent((warningCount <= 999 ? warningCount.ToString() : "999+"), warningCount > 0 ? iconWarnSmall : iconWarnMono), Constants.MiniButton); bool setErrorFlag = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelError), new GUIContent((errorCount <= 999 ? errorCount.ToString() : "999+"), errorCount > 0 ? iconErrorSmall : iconErrorMono), Constants.MiniButton); // Active entry index may no longer be valid if (EditorGUI.EndChangeCheck()) { SetActiveEntry(null); } SetFlag(ConsoleFlags.LogLevelLog, setLogFlag); SetFlag(ConsoleFlags.LogLevelWarning, setWarningFlag); SetFlag(ConsoleFlags.LogLevelError, setErrorFlag); GUILayout.EndHorizontal(); // Console entries SplitterGUILayout.BeginVerticalSplit(spl); int rowHeight = RowHeight; EditorGUIUtility.SetIconSize(new Vector2(rowHeight, rowHeight)); GUIContent tempContent = new GUIContent(); int id = GUIUtility.GetControlID(0); int rowDoubleClicked = -1; /////@TODO: Make Frame selected work with ListViewState using (new GettingLogEntriesScope(m_ListView)) { int selectedRow = -1; bool openSelectedItem = false; bool collapsed = HasFlag(ConsoleFlags.Collapse); foreach (ListViewElement el in ListViewGUI.ListView(m_ListView, Constants.Box)) { if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition)) { selectedRow = m_ListView.row; if (e.clickCount == 2) { openSelectedItem = true; } } else if (e.type == EventType.Repaint) { int mode = 0; string text = null; LogEntries.GetLinesAndModeFromEntryInternal(el.row, Constants.LogStyleLineCount, ref mode, ref text); // Draw the background GUIStyle s = el.row % 2 == 0 ? Constants.OddBackground : Constants.EvenBackground; s.Draw(el.position, false, false, m_ListView.row == el.row, false); // Draw the icon GUIStyle iconStyle = GetStyleForErrorMode(mode, true, Constants.LogStyleLineCount == 1); iconStyle.Draw(el.position, false, false, m_ListView.row == el.row, false); // Draw the text tempContent.text = text; GUIStyle errorModeStyle = GetStyleForErrorMode(mode, false, Constants.LogStyleLineCount == 1); if (string.IsNullOrEmpty(m_SearchText)) { errorModeStyle.Draw(el.position, tempContent, id, m_ListView.row == el.row); } else { //the whole text contains the searchtext, we have to know where it is int startIndex = text.IndexOf(m_SearchText, StringComparison.OrdinalIgnoreCase); if (startIndex == -1) // the searchtext is not in the visible text, we don't show the selection { errorModeStyle.Draw(el.position, tempContent, id, m_ListView.row == el.row); } else // the searchtext is visible, we show the selection { int endIndex = startIndex + m_SearchText.Length; const bool isActive = false; const bool hasKeyboardFocus = true; // This ensure we draw the selection text over the label. const bool drawAsComposition = false; Color selectionColor = GUI.skin.settings.selectionColor; errorModeStyle.DrawWithTextSelection(el.position, tempContent, isActive, hasKeyboardFocus, startIndex, endIndex, drawAsComposition, selectionColor); } } if (collapsed) { Rect badgeRect = el.position; tempContent.text = LogEntries.GetEntryCount(el.row) .ToString(CultureInfo.InvariantCulture); Vector2 badgeSize = Constants.CountBadge.CalcSize(tempContent); badgeRect.xMin = badgeRect.xMax - badgeSize.x; badgeRect.yMin += ((badgeRect.yMax - badgeRect.yMin) - badgeSize.y) * 0.5f; badgeRect.x -= 5f; GUI.Label(badgeRect, tempContent, Constants.CountBadge); } } } if (selectedRow != -1) { if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight) { m_ListView.scrollPos.y = m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight - 1; } } // Make sure the selected entry is up to date if (m_ListView.totalRows == 0 || m_ListView.row >= m_ListView.totalRows || m_ListView.row < 0) { if (m_ActiveText.Length != 0) { SetActiveEntry(null); } } else { LogEntry entry = new LogEntry(); LogEntries.GetEntryInternal(m_ListView.row, entry); SetActiveEntry(entry); // see if selected entry changed. if so - clear additional info LogEntries.GetEntryInternal(m_ListView.row, entry); if (m_ListView.selectionChanged || !m_ActiveText.Equals(entry.message)) { SetActiveEntry(entry); } } // Open entry using return key if ((GUIUtility.keyboardControl == m_ListView.ID) && (e.type == EventType.KeyDown) && (e.keyCode == KeyCode.Return) && (m_ListView.row != 0)) { selectedRow = m_ListView.row; openSelectedItem = true; } if (e.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1) { ms_LVHeight = ListViewGUI.ilvState.rectHeight; } if (openSelectedItem) { rowDoubleClicked = selectedRow; e.Use(); } } // Prevent dead locking in EditorMonoConsole by delaying callbacks (which can log to the console) until after LogEntries.EndGettingEntries() has been // called (this releases the mutex in EditorMonoConsole so logging again is allowed). Fix for case 1081060. if (rowDoubleClicked != -1) { LogEntries.RowGotDoubleClicked(rowDoubleClicked); } EditorGUIUtility.SetIconSize(Vector2.zero); // Display active text (We want word wrapped text with a vertical scrollbar) m_TextScroll = GUILayout.BeginScrollView(m_TextScroll, Constants.Box); string stackWithHyperlinks = StacktraceWithHyperlinks(m_ActiveText); float height = Constants.MessageStyle.CalcHeight(GUIContent.Temp(stackWithHyperlinks), position.width); EditorGUILayout.SelectableLabel(stackWithHyperlinks, Constants.MessageStyle, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinHeight(height)); GUILayout.EndScrollView(); SplitterGUILayout.EndVerticalSplit(); // Copy & Paste selected item if ((e.type == EventType.ValidateCommand || e.type == EventType.ExecuteCommand) && e.commandName == EventCommandNames.Copy && m_ActiveText != string.Empty) { if (e.type == EventType.ExecuteCommand) { EditorGUIUtility.systemCopyBuffer = m_ActiveText; } e.Use(); } }
public void OnGUI() { AboutWindow.LoadLogos(); GUILayout.Space(10f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(5f); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(AboutWindow.s_Header, GUIStyle.none, new GUILayoutOption[0]); this.ListenForSecretCodes(); string text = ""; if (InternalEditorUtility.HasFreeLicense()) { text = " Personal"; } if (InternalEditorUtility.HasEduLicense()) { text = " Edu"; } GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(52f); string text2 = this.FormatExtensionVersionString(); this.m_ShowDetailedVersion |= Event.current.alt; if (this.m_ShowDetailedVersion) { int unityVersionDate = InternalEditorUtility.GetUnityVersionDate(); DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); string unityBuildBranch = InternalEditorUtility.GetUnityBuildBranch(); string text3 = ""; if (unityBuildBranch.Length > 0) { text3 = "Branch: " + unityBuildBranch; } EditorGUILayout.SelectableLabel(string.Format("Version {0}{1}{2}\n{3:r}\n{4}", new object[] { InternalEditorUtility.GetFullUnityVersion(), text, text2, dateTime.AddSeconds((double)unityVersionDate), text3 }), new GUILayoutOption[] { GUILayout.Width(550f), GUILayout.Height(42f) }); this.m_TextInitialYPos = 108f; } else { GUILayout.Label(string.Format("Version {0}{1}{2}", Application.unityVersion, text, text2), new GUILayoutOption[0]); } if (Event.current.type != EventType.ValidateCommand) { GUILayout.EndHorizontal(); GUILayout.Space(4f); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); float creditsWidth = base.position.width - 10f; float num = this.m_TextYPos; Rect rect = GUILayoutUtility.GetRect(10f, this.m_TextInitialYPos); GUI.BeginGroup(rect); string[] array = AboutWindowNames.Names(null, true); for (int i = 0; i < array.Length; i++) { string nameChunk = array[i]; num = AboutWindow.DoCreditsNameChunk(nameChunk, creditsWidth, num); } num = AboutWindow.DoCreditsNameChunk("Thanks to Forest 'Yoggy' Johnson, Graham McAllister, David Janik-Jones, Raimund Schumacher, Alan J. Dickins and Emil 'Humus' Persson", creditsWidth, num); this.m_TotalCreditsHeight = num - this.m_TextYPos; GUI.EndGroup(); this.HandleScrollEvents(rect); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label(AboutWindow.s_MonoLogo, new GUILayoutOption[0]); GUILayout.Label("Scripting powered by The Mono Project.\n\n(c) 2011 Novell, Inc.", "MiniLabel", new GUILayoutOption[] { GUILayout.Width(200f) }); GUILayout.Label(AboutWindow.s_AgeiaLogo, new GUILayoutOption[0]); GUILayout.Label("Physics powered by PhysX.\n\n(c) 2011 NVIDIA Corporation.", "MiniLabel", new GUILayoutOption[] { GUILayout.Width(200f) }); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(5f); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); string aboutWindowLabel = UnityVSSupport.GetAboutWindowLabel(); if (aboutWindowLabel.Length > 0) { GUILayout.Label(aboutWindowLabel, "MiniLabel", new GUILayoutOption[0]); } GUILayout.Label(InternalEditorUtility.GetUnityCopyright(), "MiniLabel", new GUILayoutOption[0]); GUILayout.EndVertical(); GUILayout.Space(10f); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(InternalEditorUtility.GetLicenseInfo(), "AboutWindowLicenseLabel", new GUILayoutOption[0]); GUILayout.EndVertical(); GUILayout.Space(5f); GUILayout.EndHorizontal(); GUILayout.Space(5f); } }
public void OnGUI() { LoadLogos(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Space(5); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUILayout.Label(s_Header, GUIStyle.none); ListenForSecretCodes(); var licenseTypeString = ""; if (InternalEditorUtility.HasFreeLicense()) { licenseTypeString = " Personal"; } if (InternalEditorUtility.HasEduLicense()) { licenseTypeString = " Edu"; } GUILayout.BeginHorizontal(); GUILayout.Space(52f); // Ident version information string extensionVersion = FormatExtensionVersionString(); m_ShowDetailedVersion |= Event.current.alt; if (m_ShowDetailedVersion) { int t = InternalEditorUtility.GetUnityVersionDate(); DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0); string branch = InternalEditorUtility.GetUnityBuildBranch(); EditorGUILayout.SelectableLabel( string.Format("Version: {0}{1}{2}\nRevision: {3} {4}\nBuilt: {5:r}", InternalEditorUtility.GetUnityDisplayVersionVerbose(), licenseTypeString, extensionVersion, branch, InternalEditorUtility.GetUnityBuildHash(), dt.AddSeconds(t)), GUILayout.Width(550), GUILayout.Height(50)); m_TextInitialYPos = 120 - 12; } else { GUILayout.Label(string.Format("Version {0}{1}{2}", InternalEditorUtility.GetUnityDisplayVersion(), licenseTypeString, extensionVersion)); } if (Event.current.type == EventType.ValidateCommand) { return; } GUILayout.EndHorizontal(); GUILayout.Space(4); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); float creditsWidth = position.width - 10; float chunkOffset = m_TextYPos; Rect scrollAreaRect = GUILayoutUtility.GetRect(10, m_TextInitialYPos); GUI.BeginGroup(scrollAreaRect); foreach (string nameChunk in AboutWindowNames.Names(null, true)) { chunkOffset = DoCreditsNameChunk(nameChunk, creditsWidth, chunkOffset); } chunkOffset = DoCreditsNameChunk(kSpecialThanksNames, creditsWidth, chunkOffset); m_TotalCreditsHeight = chunkOffset - m_TextYPos; GUI.EndGroup(); HandleScrollEvents(scrollAreaRect); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.Label(s_MonoLogo); GUILayout.Label("Scripting powered by The Mono Project.\n\n(c) 2011 Novell, Inc.", "MiniLabel", GUILayout.Width(210)); GUILayout.Label(s_AgeiaLogo); GUILayout.Label("Physics powered by PhysX.\n\n(c) 2019 NVIDIA Corporation.", "MiniLabel", GUILayout.Width(200)); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.Space(5); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); var specialThanksRect = GUILayoutUtility.GetRect(Styles.thanksContent, Styles.thanksStyle); if (GUI.Button(specialThanksRect, Styles.thanksContent, Styles.thanksStyle)) { Process.Start(Styles.thanksUri.AbsoluteUri); } EditorGUIUtility.AddCursorRect(specialThanksRect, MouseCursor.Link); var VSTUlabel = UnityVSSupport.GetAboutWindowLabel(); if (VSTUlabel.Length > 0) { GUILayout.Label(VSTUlabel, "MiniLabel"); } GUILayout.Label(InternalEditorUtility.GetUnityCopyright(), "MiniLabel"); GUILayout.EndVertical(); GUILayout.Space(10); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUILayout.Label(InternalEditorUtility.GetLicenseInfo(), "AboutWindowLicenseLabel"); GUILayout.EndVertical(); GUILayout.Space(5); GUILayout.EndHorizontal(); GUILayout.Space(5); }
public override void OnInspectorGUI() { serializedObject.Update(); using (new EditorGUI.DisabledScope(false)) { var isManagedPlugin = importers.All(x => x.dllType == DllType.ManagedNET35 || x.dllType == DllType.ManagedNET40); if (isManagedPlugin) { ShowReferenceOptions(); GUILayout.Space(10f); } GUILayout.Label(Styles.kPluginPlatforms, EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); ShowGeneralOptions(); EditorGUILayout.EndVertical(); GUILayout.Space(10f); if (IsEditingPlatformSettingsSupported()) { ShowPlatformSettings(); } if (isManagedPlugin) { GUILayout.Label(Styles.kDefineConstraints, EditorStyles.boldLabel); if (m_DefineConstraints.list.Count > 0) { var defines = InternalEditorUtility.GetCompilationDefines(EditorScriptCompilationOptions.BuildingForEditor, EditorUserBuildSettings.activeBuildTargetGroup, EditorUserBuildSettings.activeBuildTarget); var defineConstraintsCompatible = true; if (defines != null) { for (var i = 0; i < m_DefineConstraints.list.Count && defineConstraintsCompatible; ++i) { var defineConstraint = ((DefineConstraint)m_DefineConstraints.list[i]).name; if (DefineConstraintsHelper.GetDefineConstraintCompatibility(defines, defineConstraint) != DefineConstraintsHelper.DefineConstraintStatus.Compatible) { defineConstraintsCompatible = false; } } var constraintValidityRect = new Rect(GUILayoutUtility.GetLastRect()); constraintValidityRect.x = constraintValidityRect.width - Styles.kValidityIconWidth / 4; var image = defineConstraintsCompatible ? Styles.validDefineConstraint : Styles.invalidDefineConstraint; var tooltip = Styles.GetTitleTooltipFromDefineConstraintCompatibility(defineConstraintsCompatible); var content = new GUIContent(image, tooltip); constraintValidityRect.width = Styles.kValidityIconWidth; constraintValidityRect.height = Styles.kValidityIconHeight; EditorGUI.LabelField(constraintValidityRect, content); } } m_DefineConstraints.DoLayoutList(); } if (importers.All(imp => imp.isNativePlugin)) { GUILayout.Space(10f); GUILayout.Label(Styles.kLoadSettings, EditorStyles.boldLabel); ShowLoadSettings(); } } serializedObject.ApplyModifiedProperties(); ApplyRevertGUI(); // Don't output additional information if we have multiple plugins selected if (targets.Length > 1) { return; } GUILayout.Label(Styles.kInformation, EditorStyles.boldLabel); m_InformationScrollPosition = EditorGUILayout.BeginVerticalScrollView(m_InformationScrollPosition); foreach (var prop in m_PluginInformation) { GUILayout.BeginHorizontal(); GUILayout.Label(prop.Key, GUILayout.Width(85)); EditorGUILayout.SelectableLabel(prop.Value, GUILayout.Height(EditorGUI.kSingleLineHeight)); GUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); // Warning for Case 648027 // Once Mono loads a native plugin, it never releases a handle, thus plugin is never unloaded. if (importer.isNativePlugin) { EditorGUILayout.HelpBox("Once a native plugin is loaded from script, it's never unloaded. If you deselect a native plugin and it's already loaded, please restart Unity.", MessageType.Warning); } }
internal void OnGUI() { Event e = Event.current; LoadIcons(); if (!m_HasUpdatedGuiStyles) { m_LineHeight = Mathf.RoundToInt(Constants.ErrorStyle.lineHeight); m_BorderHeight = Constants.ErrorStyle.border.top + Constants.ErrorStyle.border.bottom; UpdateListView(); } GUILayout.BeginHorizontal(Constants.Toolbar); // Clear button and clearing options bool clearClicked = false; if (EditorGUILayout.DropDownToggle(ref clearClicked, Constants.Clear, EditorStyles.toolbarDropDownToggle)) { var clearOnPlay = HasFlag(ConsoleFlags.ClearOnPlay); var clearOnBuild = HasFlag(ConsoleFlags.ClearOnBuild); var clearOnRecompile = HasFlag(ConsoleFlags.ClearOnRecompile); GenericMenu menu = new GenericMenu(); menu.AddItem(Constants.ClearOnPlay, clearOnPlay, () => { SetFlag(ConsoleFlags.ClearOnPlay, !clearOnPlay); }); menu.AddItem(Constants.ClearOnBuild, clearOnBuild, () => { SetFlag(ConsoleFlags.ClearOnBuild, !clearOnBuild); }); menu.AddItem(Constants.ClearOnRecompile, clearOnRecompile, () => { SetFlag(ConsoleFlags.ClearOnRecompile, !clearOnRecompile); }); var rect = GUILayoutUtility.GetLastRect(); rect.y += EditorGUIUtility.singleLineHeight; menu.DropDown(rect); } if (clearClicked) { LogEntries.Clear(); GUIUtility.keyboardControl = 0; } int currCount = LogEntries.GetCount(); bool showSearchNoResultMessage = currCount == 0 && !String.IsNullOrEmpty(m_SearchText); if (m_ListView.totalRows != currCount) { // scroll bar was at the bottom? if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight) { m_ListView.scrollPos.y = currCount * RowHeight - ms_LVHeight; } } bool wasCollapsed = HasFlag(ConsoleFlags.Collapse); SetFlag(ConsoleFlags.Collapse, GUILayout.Toggle(wasCollapsed, Constants.Collapse, Constants.MiniButton)); bool collapsedChanged = (wasCollapsed != HasFlag(ConsoleFlags.Collapse)); if (collapsedChanged) { // unselect if collapsed flag changed m_ListView.row = -1; // scroll to bottom m_ListView.scrollPos.y = LogEntries.GetCount() * RowHeight; } if (HasSpaceForExtraButtons()) { SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPause, Constants.MiniButton)); PlayerConnectionGUILayout.ConnectionTargetSelectionDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown, (int)(position.width - k_HasSpaceForExtraButtonsCutoff) + 80); } GUILayout.FlexibleSpace(); // Search bar if (HasSpaceForExtraButtons()) { SearchField(e); } // Flags int errorCount = 0, warningCount = 0, logCount = 0; LogEntries.GetCountsByType(ref errorCount, ref warningCount, ref logCount); EditorGUI.BeginChangeCheck(); bool setLogFlag = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelLog), new GUIContent((logCount <= 999 ? logCount.ToString() : "999+"), logCount > 0 ? iconInfoSmall : iconInfoMono), Constants.MiniButton); bool setWarningFlag = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelWarning), new GUIContent((warningCount <= 999 ? warningCount.ToString() : "999+"), warningCount > 0 ? iconWarnSmall : iconWarnMono), Constants.MiniButton); bool setErrorFlag = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelError), new GUIContent((errorCount <= 999 ? errorCount.ToString() : "999+"), errorCount > 0 ? iconErrorSmall : iconErrorMono), Constants.MiniButtonRight); // Active entry index may no longer be valid if (EditorGUI.EndChangeCheck()) { SetActiveEntry(null); m_LastActiveEntryIndex = -1; } SetFlag(ConsoleFlags.LogLevelLog, setLogFlag); SetFlag(ConsoleFlags.LogLevelWarning, setWarningFlag); SetFlag(ConsoleFlags.LogLevelError, setErrorFlag); GUILayout.EndHorizontal(); if (showSearchNoResultMessage) { Rect r = new Rect(0, EditorGUI.kSingleLineHeight, ms_ConsoleWindow.position.width, ms_ConsoleWindow.position.height - EditorGUI.kSingleLineHeight); GUI.Box(r, m_ConsoleSearchNoResultMsg, Constants.ConsoleSearchNoResult); } else { // Console entries SplitterGUILayout.BeginVerticalSplit(spl); GUIContent tempContent = new GUIContent(); int id = GUIUtility.GetControlID(0); int rowDoubleClicked = -1; /////@TODO: Make Frame selected work with ListViewState using (new GettingLogEntriesScope(m_ListView)) { int selectedRow = -1; bool openSelectedItem = false; bool collapsed = HasFlag(ConsoleFlags.Collapse); float scrollPosY = m_ListView.scrollPos.y; foreach (ListViewElement el in ListViewGUI.ListView(m_ListView, ListViewOptions.wantsRowMultiSelection, Constants.Box)) { // Destroy latest restore entry if needed if (e.type == EventType.ScrollWheel || e.type == EventType.Used) { DestroyLatestRestoreEntry(); } // Make sure that scrollPos.y is always up to date after restoring last entry if (m_RestoreLatestSelection) { m_ListView.scrollPos.y = scrollPosY; } if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition)) { selectedRow = m_ListView.row; DestroyLatestRestoreEntry(); LogEntry entry = new LogEntry(); LogEntries.GetEntryInternal(m_ListView.row, entry); m_LastActiveEntryIndex = entry.globalLineIndex; if (e.clickCount == 2) { openSelectedItem = true; } } else if (e.type == EventType.Repaint) { int mode = 0; string text = null; LogEntries.GetLinesAndModeFromEntryInternal(el.row, Constants.LogStyleLineCount, ref mode, ref text); bool entryIsSelected = m_ListView.selectedItems != null && el.row < m_ListView.selectedItems.Length && m_ListView.selectedItems[el.row]; // offset value in x for icon and text var offset = Constants.LogStyleLineCount == 1 ? 4 : 8; // Draw the background GUIStyle s = el.row % 2 == 0 ? Constants.OddBackground : Constants.EvenBackground; s.Draw(el.position, false, false, entryIsSelected, false); // Draw the icon GUIStyle iconStyle = GetStyleForErrorMode(mode, true, Constants.LogStyleLineCount == 1); Rect iconRect = el.position; iconRect.x += offset; iconRect.y += 2; iconStyle.Draw(iconRect, false, false, entryIsSelected, false); // Draw the text tempContent.text = text; GUIStyle errorModeStyle = GetStyleForErrorMode(mode, false, Constants.LogStyleLineCount == 1); var textRect = el.position; textRect.x += offset; if (string.IsNullOrEmpty(m_SearchText)) { errorModeStyle.Draw(textRect, tempContent, id, m_ListView.row == el.row); } else if (text != null) { //the whole text contains the searchtext, we have to know where it is int startIndex = text.IndexOf(m_SearchText, StringComparison.OrdinalIgnoreCase); if (startIndex == -1 ) // the searchtext is not in the visible text, we don't show the selection { errorModeStyle.Draw(textRect, tempContent, id, m_ListView.row == el.row); } else // the searchtext is visible, we show the selection { int endIndex = startIndex + m_SearchText.Length; const bool isActive = false; const bool hasKeyboardFocus = true; // This ensure we draw the selection text over the label. const bool drawAsComposition = false; Color selectionColor = GUI.skin.settings.selectionColor; errorModeStyle.DrawWithTextSelection(textRect, tempContent, isActive, hasKeyboardFocus, startIndex, endIndex, drawAsComposition, selectionColor); } } if (collapsed) { Rect badgeRect = el.position; tempContent.text = LogEntries.GetEntryCount(el.row) .ToString(CultureInfo.InvariantCulture); Vector2 badgeSize = Constants.CountBadge.CalcSize(tempContent); if (Constants.CountBadge.fixedHeight > 0) { badgeSize.y = Constants.CountBadge.fixedHeight; } badgeRect.xMin = badgeRect.xMax - badgeSize.x; badgeRect.yMin += ((badgeRect.yMax - badgeRect.yMin) - badgeSize.y) * 0.5f; badgeRect.x -= 5f; GUI.Label(badgeRect, tempContent, Constants.CountBadge); } } } if (selectedRow != -1) { if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight) { m_ListView.scrollPos.y = m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight - 1; } } // Make sure the selected entry is up to date if (m_ListView.totalRows == 0 || m_ListView.row >= m_ListView.totalRows || m_ListView.row < 0) { if (m_ActiveText.Length != 0) { SetActiveEntry(null); DestroyLatestRestoreEntry(); } } else { LogEntry entry = new LogEntry(); LogEntries.GetEntryInternal(m_ListView.row, entry); SetActiveEntry(entry); m_LastActiveEntryIndex = entry.globalLineIndex; // see if selected entry changed. if so - clear additional info LogEntries.GetEntryInternal(m_ListView.row, entry); if (m_ListView.selectionChanged || !m_ActiveText.Equals(entry.message)) { SetActiveEntry(entry); m_LastActiveEntryIndex = entry.globalLineIndex; } // If copy, get the messages from selected rows if (e.type == EventType.ExecuteCommand && e.commandName == EventCommandNames.Copy && m_ListView.selectedItems != null) { m_CopyString.Clear(); for (int rowIndex = 0; rowIndex < m_ListView.selectedItems.Length; rowIndex++) { if (m_ListView.selectedItems[rowIndex]) { LogEntries.GetEntryInternal(rowIndex, entry); m_CopyString.AppendLine(entry.message); } } } } // Open entry using return key if ((GUIUtility.keyboardControl == m_ListView.ID) && (e.type == EventType.KeyDown) && (e.keyCode == KeyCode.Return) && (m_ListView.row != 0)) { selectedRow = m_ListView.row; openSelectedItem = true; } if (e.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1) { ms_LVHeight = ListViewGUI.ilvState.rectHeight; } if (openSelectedItem) { rowDoubleClicked = selectedRow; e.Use(); } } // Prevent dead locking in EditorMonoConsole by delaying callbacks (which can log to the console) until after LogEntries.EndGettingEntries() has been // called (this releases the mutex in EditorMonoConsole so logging again is allowed). Fix for case 1081060. if (rowDoubleClicked != -1) { LogEntries.RowGotDoubleClicked(rowDoubleClicked); } // Display active text (We want word wrapped text with a vertical scrollbar) m_TextScroll = GUILayout.BeginScrollView(m_TextScroll, Constants.Box); string stackWithHyperlinks = StacktraceWithHyperlinks(m_ActiveText, m_CallstackTextStart); float height = Constants.MessageStyle.CalcHeight(GUIContent.Temp(stackWithHyperlinks), position.width); EditorGUILayout.SelectableLabel(stackWithHyperlinks, Constants.MessageStyle, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinHeight(height + 10)); GUILayout.EndScrollView(); SplitterGUILayout.EndVerticalSplit(); } // Copy & Paste selected item if ((e.type == EventType.ValidateCommand || e.type == EventType.ExecuteCommand) && e.commandName == EventCommandNames.Copy && m_CopyString != null) { if (e.type == EventType.ExecuteCommand) { EditorGUIUtility.systemCopyBuffer = m_CopyString.ToString(); } e.Use(); } if (!ms_ConsoleWindow) { ms_ConsoleWindow = this; } }
private void RenderNetworkVariableValueType <T>(int index) where T : struct { var networkVariable = (NetworkVariable <T>)m_NetworkVariableFields[m_NetworkVariableNames[index]].GetValue(target); var type = typeof(T); object val = networkVariable.Value; string name = m_NetworkVariableNames[index]; if (NetworkManager.Singleton != null && NetworkManager.Singleton.IsListening) { if (type == typeof(int)) { val = EditorGUILayout.IntField(name, (int)val); } else if (type == typeof(uint)) { val = (uint)EditorGUILayout.LongField(name, (long)((uint)val)); } else if (type == typeof(short)) { val = (short)EditorGUILayout.IntField(name, (int)((short)val)); } else if (type == typeof(ushort)) { val = (ushort)EditorGUILayout.IntField(name, (int)((ushort)val)); } else if (type == typeof(sbyte)) { val = (sbyte)EditorGUILayout.IntField(name, (int)((sbyte)val)); } else if (type == typeof(byte)) { val = (byte)EditorGUILayout.IntField(name, (int)((byte)val)); } else if (type == typeof(long)) { val = EditorGUILayout.LongField(name, (long)val); } else if (type == typeof(ulong)) { val = (ulong)EditorGUILayout.LongField(name, (long)((ulong)val)); } else if (type == typeof(bool)) { val = EditorGUILayout.Toggle(name, (bool)val); } else if (type == typeof(string)) { val = EditorGUILayout.TextField(name, (string)val); } else if (type.IsEnum) { val = EditorGUILayout.EnumPopup(name, (Enum)val); } else { EditorGUILayout.LabelField("Type not renderable"); } networkVariable.Value = (T)val; } else { EditorGUILayout.LabelField(name, EditorStyles.wordWrappedLabel); EditorGUILayout.SelectableLabel(val.ToString(), EditorStyles.wordWrappedLabel); } }