public override void OnInspectorGUI() { base.OnInspectorGUI(); NGraphUtils.DrawSeparator(); UINgraph pGraph = (UINgraph)target; 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) { Font fnt = (Font)EditorGUILayout.ObjectField(pGraph.AxisLabelDynamicFont, typeof(Font), false, GUILayout.Width(140f)); if (fnt != pGraph.AxisLabelDynamicFont) { UndoableAction <UINgraph>(gr => gr.AxisLabelDynamicFont = fnt); } } else { UIFont fnt = (UIFont)EditorGUILayout.ObjectField(pGraph.AxisLabelBitmapFont, typeof(UIFont), false, GUILayout.Width(140f)); if (fnt != pGraph.AxisLabelBitmapFont) { UndoableAction <UINgraph>(gr => gr.AxisLabelBitmapFont = fnt); } } mType = (UILabelInspector.FontType)EditorGUILayout.EnumPopup(mType, GUILayout.Width(62f)); #else UIFont fnt = (UIFont)EditorGUILayout.ObjectField(pGraph.AxisLabelBitmapFont, typeof(UIFont), false, GUILayout.Width(140f)); if (fnt != pGraph.AxisLabelBitmapFont) { UndoableAction <UINgraph>(gr => gr.AxisLabelBitmapFont = fnt); } mType = UILabelInspector.FontType.NGUI; #endif GUILayout.Label("size", GUILayout.Width(30f)); EditorGUI.BeginDisabledGroup(mType == UILabelInspector.FontType.NGUI); int i = EditorGUILayout.IntField(pGraph.fontSize, GUILayout.Width(30f)); if (i != pGraph.fontSize) { UndoableAction <UINgraph>(gr => gr.fontSize = i); } EditorGUI.EndDisabledGroup(); GUILayout.Label("font used by the labels"); GUILayout.EndHorizontal(); }
void OnDynamicFont(Object obj) { UINgraph pGraph = (UINgraph)target; pGraph.AxisLabelDynamicFont = obj as Font; pGraph.AxisLabelBitmapFont = null; }
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; } } }