UnityEditor.EditorGUILayout.SelectableLabel C# (CSharp) Method

SelectableLabel() public static method

Make a selectable label field. (Useful for showing read-only info that can be copy-pasted.)

public static SelectableLabel ( string text ) : void
text string The text to show.
return void
        public static void SelectableLabel(string text, params GUILayoutOption[] options)
        {
            SelectableLabel(text, EditorStyles.label, options);
        }

Same methods

EditorGUILayout::SelectableLabel ( string text, GUIStyle style ) : void

Usage Example

示例#1
0
        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);
                    }
                }
            }
        }
All Usage Examples Of UnityEditor.EditorGUILayout::SelectableLabel