#if UNITY_EDITOR using DTT.Utils.EditorUtilities; using UnityEditor; using UnityEngine; namespace DTT.PublishingTools { /// /// Additional styles used for styling a GUI in DTT style. Styles /// will differ based on Unity's Dark/Light theme. /// public class DTTGUIStyles : GUIStyleCache { #region Variables #region Public /// /// A style for a normal label. /// public GUIStyle Label => base[nameof(Label)]; /// /// A style for a label that uses the dtt title font. /// public GUIStyle TitleLabel => base[nameof(TitleLabel)]; /// /// The style for a card header. /// public GUIStyle CardHeader => base[nameof(CardHeader)]; /// /// The style for a card body. /// public GUIStyle CardBody => base[nameof(CardBody)]; /// /// The style for a button. /// public GUIStyle Button => base[nameof(Button)]; #endregion #region Private /// /// The normal color of link text when not in pro mode. /// private readonly Color _lightBlueLinkColor = new Color32(0, 82, 255, 255); #endregion #endregion #region Constructors /// /// Creates a new instance, initializing the styles. /// public DTTGUIStyles() { Add(nameof(Label), () => { GUIStyle style = new GUIStyle(DTTGUI.Skin.label); style.normal.textColor = EditorStyles.label.normal.textColor; style.fontSize = 12; return style; }); Add(nameof(TitleLabel), () => { GUIStyle style = new GUIStyle(DTTGUI.Skin.label); style.font = DTTGUI.TitleFont; style.normal.textColor = EditorStyles.label.normal.textColor; style.fontSize = 12; return style; }); Add(nameof(CardHeader), () => { GUIStyle style = new GUIStyle(DTTGUI.Skin.box); // No scaled backgrounds should be used, only use the card background texture. style.normal.scaledBackgrounds = null; style.normal.background = EditorGUIUtility.isProSkin ? DTTTextures.dark.CardHeader : DTTTextures.light.CardHeader; // The border property ensures the rounding of the edges persists with stretch. style.border = new RectOffset(16, 16, 16, 16); // Set the margin and padding to work with the card body. style.margin.top = 8; style.margin.left = 8; style.margin.right = 8; style.margin.bottom = 0; style.padding = new RectOffset(15, 15, 15, 15); return style; }); Add(nameof(CardBody), () => { GUIStyle style = new GUIStyle(DTTGUI.Skin.box); // No scaled backgrounds should be used, only use the card background texture. style.normal.scaledBackgrounds = null; style.normal.background = EditorGUIUtility.isProSkin ? DTTTextures.dark.CardBody : DTTTextures.light.CardBody; // The border property ensures the rounding of the edges persists with stretch. style.border = new RectOffset(16, 16, 16, 16); // Set the margin and padding to work with the card header. style.margin.top = 0; style.margin.left = 8; style.margin.right = 8; style.padding = new RectOffset(15, 15, 15, 15); return style; }); Add(nameof(Button), () => { GUIStyle style = new GUIStyle(DTTGUI.Skin.button); style.normal = EditorStyles.miniButton.normal; style.hover = EditorStyles.miniButton.hover; style.active = EditorStyles.miniButton.active; return style; }); } #endregion } } #endif