public static void Title(string text, Color backgroundColor, params GUILayoutOption[] options) { var titleStyle = new TitleGUIStyle() { backgroundColor = backgroundColor, }; Title(text, titleStyle); }
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); } } }