本文整理汇总了C#中UIFont.AddSymbol方法的典型用法代码示例。如果您正苦于以下问题:C# UIFont.AddSymbol方法的具体用法?C# UIFont.AddSymbol怎么用?C# UIFont.AddSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIFont
的用法示例。
在下文中一共展示了UIFont.AddSymbol方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInspectorGUI
//.........这里部分代码省略.........
if (pixelSize != mFont.pixelSize)
{
NGUIEditorTools.RegisterUndo("Font Change", mFont);
mFont.pixelSize = pixelSize;
}
}
EditorGUILayout.Space();
}
// Preview option
if (!mFont.isDynamic && mFont.atlas != null)
{
GUILayout.BeginHorizontal();
{
mView = (View)EditorGUILayout.EnumPopup("Preview", mView);
GUILayout.Label("Shader", GUILayout.Width(45f));
mUseShader = EditorGUILayout.Toggle(mUseShader, GUILayout.Width(20f));
}
GUILayout.EndHorizontal();
}
// Dynamic fonts don't support emoticons
if (!mFont.isDynamic && mFont.bmFont.isValid)
{
if (mFont.atlas != null)
{
if (NGUIEditorTools.DrawHeader("Symbols and Emoticons"))
{
NGUIEditorTools.BeginContents();
List<BMSymbol> symbols = mFont.symbols;
for (int i = 0; i < symbols.Count; )
{
BMSymbol sym = symbols[i];
GUILayout.BeginHorizontal();
GUILayout.Label(sym.sequence, GUILayout.Width(40f));
if (NGUIEditorTools.SimpleSpriteField(mFont.atlas, sym.spriteName, ChangeSymbolSprite))
mSelectedSymbol = sym;
if (GUILayout.Button("Edit", GUILayout.Width(40f)))
{
if (mFont.atlas != null)
{
NGUISettings.selectedSprite = sym.spriteName;
NGUIEditorTools.Select(mFont.atlas.gameObject);
}
}
GUI.backgroundColor = Color.red;
if (GUILayout.Button("X", GUILayout.Width(22f)))
{
NGUIEditorTools.RegisterUndo("Remove symbol", mFont);
mSymbolSequence = sym.sequence;
mSymbolSprite = sym.spriteName;
symbols.Remove(sym);
mFont.MarkAsDirty();
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
GUILayout.Space(4f);
++i;
}
if (symbols.Count > 0)
{
GUILayout.Space(6f);
}
GUILayout.BeginHorizontal();
mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f));
NGUIEditorTools.SimpleSpriteField(mFont.atlas, mSymbolSprite, SelectSymbolSprite);
bool isValid = !string.IsNullOrEmpty(mSymbolSequence) && !string.IsNullOrEmpty(mSymbolSprite);
GUI.backgroundColor = isValid ? Color.green : Color.grey;
if (GUILayout.Button("Add", GUILayout.Width(40f)) && isValid)
{
NGUIEditorTools.RegisterUndo("Add symbol", mFont);
mFont.AddSymbol(mSymbolSequence, mSymbolSprite);
mFont.MarkAsDirty();
mSymbolSequence = "";
mSymbolSprite = "";
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
if (symbols.Count == 0)
{
EditorGUILayout.HelpBox("Want to add an emoticon to your font? In the field above type ':)', choose a sprite, then hit the Add button.", MessageType.Info);
}
else GUILayout.Space(4f);
NGUIEditorTools.EndContents();
}
}
}
}
示例2: OnInspectorGUI
//.........这里部分代码省略.........
}
GUI.backgroundColor = Color.red;
if (GUILayout.Button("X", GUILayout.Width(22f)))
{
NGUIEditorTools.RegisterUndo("Remove symbol", mFont);
mSymbolSequence = sym.sequence;
mSymbolSprite = sym.spriteName;
symbols.Remove(sym);
mFont.MarkAsChanged();
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
GUILayout.Space(4f);
++i;
}
if (symbols.Count > 0)
{
GUILayout.Space(6f);
}
GUILayout.BeginHorizontal();
mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f));
NGUIEditorTools.DrawSpriteField(mFont.atlas, mSymbolSprite, SelectSymbolSprite);
bool isValid = !string.IsNullOrEmpty(mSymbolSequence) && !string.IsNullOrEmpty(mSymbolSprite);
GUI.backgroundColor = isValid ? Color.green : Color.grey;
if (GUILayout.Button("Add", GUILayout.Width(40f)) && isValid)
{
NGUIEditorTools.RegisterUndo("Add symbol", mFont);
mFont.AddSymbol(mSymbolSequence, mSymbolSprite);
mFont.MarkAsChanged();
mSymbolSequence = "";
mSymbolSprite = "";
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
if (symbols.Count == 0)
{
EditorGUILayout.HelpBox("Want to add an emoticon to your font? In the field above type ':)', choose a sprite, then hit the Add button.", MessageType.Info);
}
else GUILayout.Space(4f);
NGUIEditorTools.EndContents();
}
}
}
if (mFont.bmFont != null && mFont.bmFont.isValid)
{
if (NGUIEditorTools.DrawHeader("Modify"))
{
NGUIEditorTools.BeginContents();
UISpriteData sd = mFont.sprite;
bool disable = (sd != null && (sd.paddingLeft != 0 || sd.paddingBottom != 0));
EditorGUI.BeginDisabledGroup(disable || mFont.packedFontShader);
EditorGUILayout.BeginHorizontal();
GUILayout.Space(20f);
EditorGUILayout.BeginVertical();
示例3: OnInspectorGUI
//.........这里部分代码省略.........
GUILayout.EndHorizontal();
if (mFont.atlas == null)
{
mView = View.Font;
mUseShader = false;
float pixelSize = EditorGUILayout.FloatField("Pixel Size", mFont.pixelSize, GUILayout.Width(120f));
if (pixelSize != mFont.pixelSize)
{
NGUIEditorTools.RegisterUndo("Font Change", mFont);
mFont.pixelSize = pixelSize;
}
}
else
{
GUILayout.Space(4f);
GUILayout.BeginHorizontal();
{
mView = (View)EditorGUILayout.EnumPopup("Preview", mView);
GUILayout.Label("Shader", GUILayout.Width(45f));
mUseShader = EditorGUILayout.Toggle(mUseShader, GUILayout.Width(20f));
}
GUILayout.EndHorizontal();
}
}
if (mFont.atlas != null)
{
NGUIEditorTools.DrawHeader("Symbols and Emoticons");
List<BMSymbol> symbols = mFont.symbols;
for (int i = 0; i < symbols.Count; )
{
BMSymbol sym = symbols[i];
GUILayout.BeginHorizontal();
GUILayout.Label(sym.sequence, GUILayout.Width(40f));
if (NGUIEditorTools.SimpleSpriteField(mFont.atlas, sym.spriteName, ChangeSymbolSprite))
mSelectedSymbol = sym;
if (GUILayout.Button("Edit", GUILayout.Width(40f)))
{
if (mFont.atlas != null)
{
EditorPrefs.SetString("NGUI Selected Sprite", sym.spriteName);
NGUIEditorTools.Select(mFont.atlas.gameObject);
}
}
GUI.backgroundColor = Color.red;
if (GUILayout.Button("X", GUILayout.Width(22f)))
{
NGUIEditorTools.RegisterUndo("Remove symbol", mFont);
mSymbolSequence = sym.sequence;
mSymbolSprite = sym.spriteName;
symbols.Remove(sym);
mFont.MarkAsDirty();
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
GUILayout.Space(4f);
++i;
}
if (symbols.Count > 0)
{
NGUIEditorTools.DrawSeparator();
}
GUILayout.BeginHorizontal();
mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f));
NGUIEditorTools.SimpleSpriteField(mFont.atlas, mSymbolSprite, SelectSymbolSprite);
bool isValid = !string.IsNullOrEmpty(mSymbolSequence) && !string.IsNullOrEmpty(mSymbolSprite);
GUI.backgroundColor = isValid ? Color.green : Color.grey;
if (GUILayout.Button("Add", GUILayout.Width(40f)) && isValid)
{
NGUIEditorTools.RegisterUndo("Add symbol", mFont);
mFont.AddSymbol(mSymbolSequence, mSymbolSprite);
mFont.MarkAsDirty();
mSymbolSequence = "";
mSymbolSprite = "";
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
if (symbols.Count == 0)
{
EditorGUILayout.HelpBox("Want to add an emoticon to your font? In the field above type ':)', choose a sprite, then hit the Add button.", MessageType.Info);
}
else GUILayout.Space(4f);
}
}
}
}