public static void Draw(this GUIStyleState current, string name = "GUIStyleState", bool compact = false, string key = null) { if (compact) { EditorGUILayout.BeginHorizontal(); EditorUI.SetLayoutOnce(200); current.textColor = current.textColor.Draw(name.ToTitleCase()); EditorUI.SetLayoutOnce(Screen.width - 240, 16); current.background = current.background.Draw <Texture2D>(null, true, false).As <Texture2D>(); EditorGUILayout.EndHorizontal(); return; } if (name.ToTitleCase().ToLabel().DrawFoldout(key)) { EditorGUI.indentLevel += 1; EditorUI.SetLayoutOnce(0, 15); current.background = current.background.Draw <Texture2D>("Background").As <Texture2D>(); current.textColor = current.textColor.Draw("Text Color"); #if UNITY_5_4_OR_NEWER if ("Scaled Backgrounds".ToLabel().DrawFoldout(key + ".Scaled")) { EditorGUI.indentLevel += 1; var size = current.scaledBackgrounds.Length; var newSize = current.scaledBackgrounds.Length.DrawIntDelayed("Size"); if (size != newSize) { current.scaledBackgrounds = current.scaledBackgrounds.Resize(newSize); EditorUI.foldoutChanged = true; } for (int index = 0; index < current.scaledBackgrounds.Length; ++index) { var background = current.scaledBackgrounds[index]; EditorUI.SetLayoutOnce(0, 15); current.scaledBackgrounds[index] = background.Draw <Texture2D>("Background").As <Texture2D>(); } EditorGUI.indentLevel -= 1; } #endif EditorGUI.indentLevel -= 1; } }
public static void DrawTextSettings(this GUIStyle current, bool compact = false) { if (compact) { EditorGUILayout.BeginHorizontal(); EditorUI.SetLayoutOnce(171); current.fontSize = current.fontSize.DrawInt("Font", EditorStyles.textField); EditorUI.SetLayoutOnce(80); current.fontStyle = current.fontStyle.Draw(null, null, false).As <FontStyle>(); EditorUI.SetLayoutOnce(Screen.width - 305 + EditorStyles.inspectorDefaultMargins.padding.left); current.font = current.font.Draw <Font>(null, false, false); EditorGUILayout.EndHorizontal(); } else { current.font = current.font.Draw <Font>("Font"); current.fontSize = current.fontSize.DrawInt("Font Size"); current.fontStyle = current.fontStyle.Draw("Font Style").As <FontStyle>(); } current.alignment = current.alignment.Draw("Alignment").As <TextAnchor>(); current.wordWrap = current.wordWrap.Draw("Word Wrap"); current.richText = current.richText.Draw("Rich Text"); current.clipping = current.clipping.Draw("Text Clipping").As <TextClipping>(); }