public override void DrawSubProperty() { state = UIModifierUtils.DrawContentHeader("UILabel", state); if (state) { #region Font EditorGUILayout.HelpBox("暂时只支持Dynamic Fonts替换", MessageType.Warning); GUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(true); Font_Type = (UILabelInspector.FontType)EditorGUILayout.EnumPopup(Font_Type, "DropDown", GUILayout.Width(74f)); EditorGUI.EndDisabledGroup(); if (GUILayout.Button("Font", "DropDown", GUILayout.Width(64f))) { ComponentSelector.Show <UIFont>(OnNGUIFont); } EditorGUILayout.ObjectField(UI_Font, typeof(UIFont), false); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Font Size", GUILayout.Width(66)); Font_Size = EditorGUILayout.IntField("", Font_Size, GUILayout.Width(142f)); Font_Style = (FontStyle)EditorGUILayout.EnumPopup(Font_Style); GUILayout.Space(18f); } GUILayout.EndHorizontal(); #endregion GUILayout.BeginHorizontal(); GUILayout.Label("Modifier", GUILayout.Width(66)); Modifier_Type = (UILabel.Modifier)EditorGUILayout.EnumPopup(Modifier_Type); GUILayout.Space(18f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Alignment", GUILayout.Width(66)); Alig_Type = (NGUIText.Alignment)EditorGUILayout.EnumPopup(Alig_Type); GUILayout.Space(18f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Effect", GUILayout.Width(66)); Effect_Type = (UILabel.Effect)EditorGUILayout.EnumPopup(Effect_Type); if (Effect_Type != UILabel.Effect.None) { Effect_Color = EditorGUILayout.ColorField(Effect_Color, GUILayout.MinWidth(10f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(" ", GUILayout.Width(66)); EditorGUIUtility.labelWidth = 20f; Effect_Distance.x = EditorGUILayout.FloatField("X", Effect_Distance.x, GUILayout.MinWidth(40f)); Effect_Distance.y = EditorGUILayout.FloatField("Y", Effect_Distance.y, GUILayout.MinWidth(40f)); EditorGUIUtility.labelWidth = 70; } } GUILayout.Space(18f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Overflow", GUILayout.Width(66)); Overflow_Method = (UILabel.Overflow)EditorGUILayout.EnumPopup(Overflow_Method); GUILayout.Space(18f); GUILayout.EndHorizontal(); //EditorGUI.indentLevel++; if (Overflow_Method == UILabel.Overflow.ClampContent) { GUILayout.BeginHorizontal(); GUILayout.Label(" ", GUILayout.Width(66)); UseEllipsis = EditorGUILayout.ToggleLeft("Use Ellipsis", UseEllipsis); GUILayout.EndHorizontal(); } else if (Overflow_Method == UILabel.Overflow.ResizeFreely) { GUILayout.BeginHorizontal(); GUILayout.Label(" ", GUILayout.Width(66)); Overflow_Width = EditorGUILayout.IntField("Max Width", Overflow_Width, GUILayout.MinWidth(100)); if (Overflow_Width < 1) { GUILayout.Label("unlimited"); } GUILayout.Space(18f); GUILayout.EndHorizontal(); } //EditorGUI.indentLevel--; GUILayout.BeginHorizontal(); Gradient = EditorGUILayout.Toggle("Gradient", Gradient, GUILayout.Width(80)); EditorGUI.BeginDisabledGroup(!Gradient); { EditorGUIUtility.labelWidth = 40; Gradient_Top_Color = EditorGUILayout.ColorField("Top", Gradient_Top_Color, GUILayout.MinWidth(60)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(" ", GUILayout.Width(80)); Gradient_Bottom_Color = EditorGUILayout.ColorField("Bottom", Gradient_Bottom_Color, GUILayout.MinWidth(60)); EditorGUIUtility.labelWidth = 70; } EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); BBCode = EditorGUILayout.Toggle("BBCode", BBCode, GUILayout.Width(80)); EditorGUI.BeginDisabledGroup(!BBCode); Symbol_Style = (NGUIText.SymbolStyle)EditorGUILayout.EnumPopup("Symbols", Symbol_Style); EditorGUI.EndDisabledGroup(); GUILayout.Space(18); GUILayout.EndHorizontal(); Max_Lines = EditorGUILayout.IntField("Max Lines", Max_Lines, GUILayout.Width(120)); EditorGUILayout.HelpBox("依据官方文档,强制修改Keep Crisp为Never", MessageType.Warning); EditorGUI.BeginDisabledGroup(true); Crisp = UILabel.Crispness.Never; GUILayout.BeginHorizontal(); GUILayout.Label("Keep Crisp", GUILayout.Width(66)); Crisp = (UILabel.Crispness)EditorGUILayout.EnumPopup(Crisp); GUILayout.Space(18f); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); } }
/// <summary> /// Draw the custom wizard. /// </summary> void OnGUI() { // Load the saved preferences if (!mLoaded) { mLoaded = true; Load(); #if DYNAMIC_FONT Object font = NGUISettings.ambigiousFont; mType = ((font != null) && (font is UIFont)) ? UILabelInspector.FontType.Bitmap : UILabelInspector.FontType.Dynamic; #else mType = UILabelInspector.FontType.Bitmap; #endif } NGUIEditorTools.SetLabelWidth(80f); GameObject go = NGUIEditorTools.SelectedRoot(); if (go == null) { GUILayout.Label("You must create a UI first."); if (GUILayout.Button("Open the New UI Wizard")) { EditorWindow.GetWindow <UICreateNewUIWizard>(false, "New UI", true); } } else { GUILayout.Space(4f); GUILayout.BeginHorizontal(); ComponentSelector.Draw <UIAtlas>(NGUISettings.atlas, OnSelectAtlas, false, GUILayout.Width(140f)); GUILayout.Label("Texture atlas used by widgets", GUILayout.Width(10000f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (NGUIEditorTools.DrawPrefixButton("Font")) { if (mType == UILabelInspector.FontType.Bitmap) { ComponentSelector.Show <UIFont>(OnFont); } else { ComponentSelector.Show <Font>(OnFont); } } #if DYNAMIC_FONT GUI.changed = false; if (mType == UILabelInspector.FontType.Dynamic) { NGUISettings.ambigiousFont = EditorGUILayout.ObjectField(NGUISettings.ambigiousFont, typeof(Font), false, GUILayout.Width(140f)); } else { NGUISettings.ambigiousFont = EditorGUILayout.ObjectField(NGUISettings.ambigiousFont, typeof(UIFont), false, GUILayout.Width(140f)); } mType = (UILabelInspector.FontType)EditorGUILayout.EnumPopup(mType, GUILayout.Width(62f)); #else NGUISettings.ambigiousFont = EditorGUILayout.ObjectField(NGUISettings.ambigiousFont, typeof(UIFont), false, GUILayout.Width(140f)); #endif GUILayout.Label("size", GUILayout.Width(30f)); EditorGUI.BeginDisabledGroup(mType == UILabelInspector.FontType.Bitmap); NGUISettings.fontSize = EditorGUILayout.IntField(NGUISettings.fontSize, GUILayout.Width(30f)); EditorGUI.EndDisabledGroup(); GUILayout.Label("font used by the labels"); GUILayout.EndHorizontal(); NGUIEditorTools.DrawSeparator(); GUILayout.BeginHorizontal(); WidgetType wt = (WidgetType)EditorGUILayout.EnumPopup("Template", mWidgetType, GUILayout.Width(200f)); GUILayout.Space(20f); GUILayout.Label("Select a widget template to use"); GUILayout.EndHorizontal(); if (mWidgetType != wt) { mWidgetType = wt; Save(); } switch (mWidgetType) { case WidgetType.Label: CreateLabel(go); break; case WidgetType.Sprite: CreateSprite(go); break; case WidgetType.Texture: CreateSimpleTexture(go); break; case WidgetType.Button: CreateButton(go); break; case WidgetType.ImageButton: CreateImageButton(go); break; case WidgetType.Toggle: CreateToggle(go); break; case WidgetType.ProgressBar: CreateSlider(go, false); break; case WidgetType.Slider: CreateSlider(go, true); break; case WidgetType.Input: CreateInput(go); break; case WidgetType.PopupList: CreatePopup(go, true); break; case WidgetType.PopupMenu: CreatePopup(go, false); break; case WidgetType.ScrollBar: CreateScrollBar(go); break; } EditorGUILayout.HelpBox("Widget Tool has become far less useful with NGUI 3.0.6. Search the Project view for 'Control', then simply drag & drop one of them into your Scene View.", MessageType.Warning); } }
public override void OnGUI() { base.OnGUI(); GUILayout.BeginHorizontal(); if (NGUIEditorTools.DrawPrefixButton("Font")) { if (mType == UILabelInspector.FontType.NGUI) { ComponentSelector.Show <UIFont>(OnBitmapFont); } else { ComponentSelector.Show <Font>(OnDynamicFont); } } #if DYNAMIC_FONT GUI.changed = false; if (mType == UILabelInspector.FontType.Unity) { mTrueTypeFont = (Font)EditorGUILayout.ObjectField(mTrueTypeFont, typeof(Font), false, GUILayout.Width(140f)); if (GUI.changed) { mBitmapFont = null; } } else { mBitmapFont = (UIFont)EditorGUILayout.ObjectField(mBitmapFont, typeof(UIFont), false, GUILayout.Width(140f)); if (GUI.changed) { mTrueTypeFont = null; } } mType = (UILabelInspector.FontType)EditorGUILayout.EnumPopup(mType, GUILayout.Width(62f)); #else NGUISettings.bitmapFont = (UIFont)EditorGUILayout.ObjectField(NGUISettings.bitmapFont, typeof(UIFont), false, GUILayout.Width(140f)); mType = UILabelInspector.FontType.NGUI; #endif GUILayout.Label("size", GUILayout.Width(30f)); EditorGUI.BeginDisabledGroup(mType == UILabelInspector.FontType.NGUI); NGUISettings.fontSize = EditorGUILayout.IntField(NGUISettings.fontSize, GUILayout.Width(30f)); EditorGUI.EndDisabledGroup(); GUILayout.Label("font used by the labels"); GUILayout.EndHorizontal(); NGUIEditorTools.DrawSeparator(); GameObject go = NGUIEditorTools.SelectedRoot(); if (ShouldCreate(go, go != null && (mBitmapFont != null || mTrueTypeFont != null))) { UINgraph pUINgraph = CreateGraphGo <UINgraph>(go); pUINgraph.fontSize = NGUISettings.fontSize; if (mType == UILabelInspector.FontType.NGUI) { pUINgraph.AxisLabelBitmapFont = mBitmapFont; } else { pUINgraph.AxisLabelDynamicFont = mTrueTypeFont; } } }