예제 #1
0
        public static void Title(string text, Color backgroundColor, params GUILayoutOption[] options)
        {
            var titleStyle = new TitleGUIStyle()
            {
                backgroundColor = backgroundColor,
            };

            Title(text, titleStyle);
        }
예제 #2
0
        public static void Title(string text, TitleGUIStyle style, params GUILayoutOption[] options)
        {
            var labelStyleState = new GUIStyleState()
            {
                textColor = style.labelColor.HasValue ? style.labelColor.Value : LabelColor,
            };

            var labelStyle = new GUIStyle("IN TextField")
            {
                alignment = style.alignment,
                fontStyle = style.fontStyle,
                normal    = labelStyleState,
            };

            var size = labelStyle.CalcSize(new GUIContent(text));

            var backgroundColor = style.backgroundColor.HasValue ? style.backgroundColor.Value : BackgroundColor;

            using (new BackgroundColorScope(backgroundColor))
            {
                var layoutOptions = new List <GUILayoutOption>()
                {
                    GUILayout.Height(size.y),
                };

                if (style.width.HasValue)
                {
                    layoutOptions.Add(GUILayout.Width(style.width.Value));
                }

                using (new EditorGUILayout.HorizontalScope(EditorStyles.textArea, layoutOptions.ToArray()))
                {
                    GUILayout.Space(10f);

                    GUILayout.Label(text, labelStyle, options);

                    GUILayout.Space(10f);
                }
            }
        }