internal void Init() { def = new GUIStyle(GUI.skin.button); tool = new GUIStyle(EditorStyles.toolbarButton).ContentOffsetY(-1); toolL = new GUIStyle(EditorStyles.toolbarButton).Height(23).ContentOffsetY(0); toolS = new GUIStyle(EditorStyles.toolbarButton).Height(13).ContentOffsetY(0).Padding(0); toolIco = new GUIStyle(tool).StretchWidth(false).Width(22).ContentOffsetX(-1); // toolFoldoutClosed = new GUIStyle(GUI.skin.button) { // alignment = TextAnchor.UpperLeft, // active = { background = null }, // fixedWidth = 14, // normal = { background = EditorStyles.foldout.normal.background }, // border = EditorStyles.foldout.border, // padding = new RectOffset(14, 0, 0, 0) // }.MarginTop(2); toolFoldoutClosed = new GUIStyle(GUI.skin.button) { alignment = TextAnchor.MiddleLeft, active = { background = null }, fixedWidth = 14, normal = { background = EditorStyles.foldout.normal.background }, border = EditorStyles.foldout.border, padding = new RectOffset(14, 0, 0, 0), margin = new RectOffset(0, 3, 0, 0), overflow = new RectOffset(-2, 0, -2, 0), stretchHeight = true, contentOffset = new Vector2(2, -1) }; toolFoldoutClosedWLabel = toolFoldoutClosed.Clone(9).Width(0).StretchWidth(false); toolFoldoutClosedWStretchedLabel = toolFoldoutClosedWLabel.Clone().StretchWidth(); toolFoldoutOpen = new GUIStyle(toolFoldoutClosed) { normal = { background = EditorStyles.foldout.onNormal.background } }; toolFoldoutOpenWLabel = new GUIStyle(toolFoldoutClosedWLabel) { normal = { background = EditorStyles.foldout.onNormal.background } }; toolFoldoutOpenWStretchedLabel = toolFoldoutOpenWLabel.Clone().StretchWidth(); // Large toolLFoldoutClosed = toolFoldoutClosed.Clone().OverflowTop(-4); toolLFoldoutClosedWLabel = toolFoldoutClosedWLabel.Clone().OverflowTop(-4); toolLFoldoutClosedWStretchedLabel = toolFoldoutClosedWStretchedLabel.Clone().OverflowTop(-4); toolLFoldoutOpen = toolFoldoutOpen.Clone().OverflowTop(-4); toolLFoldoutOpenWLabel = toolFoldoutOpenWLabel.Clone().OverflowTop(-4); toolLFoldoutOpenWStretchedLabel = toolFoldoutOpenWStretchedLabel.Clone().OverflowTop(-4); // Custom using squareBorder bBlankBorder = new GUIStyle(GUI.skin.button).Add(TextAnchor.MiddleCenter, Color.white).Background(DeStylePalette.squareBorderCurved) .Padding(0, 1, 1, 2).Border(new RectOffset(4, 4, 4, 4)).Overflow(-1, -1, 0, 0); bBlankBorderCompact = bBlankBorder.Clone().Padding(0, 1, 0, 0).ContentOffsetY(-1); flatWhite = DeGUI.styles.button.tool.Clone(TextAnchor.MiddleCenter).Background(DeStylePalette.whiteSquare).Margin(0).Padding(0) .Border(0, 0, 0, 0).Overflow(0).Height(0).ContentOffset(0, 0); transparent = flatWhite.Clone().Background(null); }
public static void Init() { if (_initialized) { return; } _initialized = true; oneRow = new GUIStyle().StretchWidth().Height((int)EditorGUIUtility.singleLineHeight); twoRows = oneRow.Clone().Height((int)EditorGUIUtility.singleLineHeight * 2 + DeAudioGUI.VSpace); threeRows = oneRow.Clone().Height((int)EditorGUIUtility.singleLineHeight * 3 + DeAudioGUI.VSpace * 2); }
public static GUIStyle ColoredClone(this GUIStyle style, Color color) { style = style.Clone(); style.normal.textColor = color; style.active.textColor = color; style.focused.textColor = color; style.hover.textColor = color; return(style); }
internal void Init() { bold = new GUIStyle(GUI.skin.label).Add(FontStyle.Bold); rightAligned = new GUIStyle(GUI.skin.label).Add(TextAnchor.MiddleRight); wordwrap = new GUIStyle(GUI.skin.label).Add(Format.WordWrap); wordwrapRichtText = wordwrap.Clone(Format.RichText); toolbar = new GUIStyle(GUI.skin.label).Add(9).ContentOffset(new Vector2(-2, 1)); toolbarRightAligned = toolbar.Clone(TextAnchor.MiddleRight); toolbarL = new GUIStyle(toolbar).ContentOffsetY(3); toolbarS = new GUIStyle(toolbar).Add(8, FontStyle.Bold).ContentOffsetY(-2); toolbarBox = new GUIStyle(toolbar).ContentOffsetY(0); }
/// <summary>Colored button</summary> public static bool ColoredButton(Rect rect, Color shade, Color contentColor, GUIContent content, GUIStyle guiStyle) { Color prevBgColor = GUI.backgroundColor; GUI.backgroundColor = shade; if (guiStyle == null) { guiStyle = DeGUI.styles.button.def; } bool clicked = GUI.Button(rect, content, guiStyle.Clone(contentColor)); GUI.backgroundColor = prevBgColor; return(clicked); }
/// <summary>Colored button</summary> public static bool ColoredButton(Color shade, Color contentColor, GUIContent content, GUIStyle guiStyle, params GUILayoutOption[] options) { Color prevBgColor = GUI.backgroundColor; GUI.backgroundColor = shade; if (guiStyle == null) { guiStyle = DeGUI.styles.button.def; } bool clicked = GUILayout.Button(content, guiStyle.Clone(contentColor), options); GUI.backgroundColor = prevBgColor; return(clicked); }
public static bool ColoredButton(Color shader, Color contentColor, GUIContent content, GUIStyle guiStyle, params GUILayoutOption[] options) { Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = shader; if (guiStyle == null) { guiStyle = DeGUI.styles.button.def; } object[] formats = new object[] { contentColor }; bool flag = GUILayout.Button(content, guiStyle.Clone(formats), options); GUI.backgroundColor = backgroundColor; return(flag); }
public static bool ToggleButton(bool toggled, GUIContent content, DeColorPalette colorPalette, GUIStyle guiStyle = null, params GUILayoutOption[] options) { DeColorPalette palette = colorPalette ?? DeGUI.colors; Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = toggled ? palette.bg.toggleOn : palette.bg.toggleOff; if (guiStyle == null) { guiStyle = DeGUI.styles.button.def; } object[] formats = new object[] { toggled?palette.content.toggleOn : palette.content.toggleOff }; if (GUILayout.Button(content, guiStyle.Clone(formats), options)) { toggled = !toggled; GUI.changed = true; } GUI.backgroundColor = backgroundColor; return(toggled); }
public static bool ToggleButton(Rect rect, bool toggled, GUIContent content, DeColorPalette colorPalette, GUIStyle guiStyle = null) { DeColorPalette palette = colorPalette ?? colors; Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = toggled ? ((Color)palette.bg.toggleOn) : ((Color)palette.bg.toggleOff); if (guiStyle == null) { guiStyle = styles.button.def; } object[] formats = new object[] { toggled?palette.content.toggleOn : palette.content.toggleOff }; if (GUI.Button(rect, content, guiStyle.Clone(formats))) { toggled = !toggled; GUI.changed = true; } GUI.backgroundColor = backgroundColor; return(toggled); }
public static GUIStyle FontStyledClone(this GUIStyle style, FontStyle fontStyle) { style = style.Clone(); style.fontStyle = fontStyle; return(style); }