本文整理汇总了C#中UIFont.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# UIFont.Refresh方法的具体用法?C# UIFont.Refresh怎么用?C# UIFont.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIFont
的用法示例。
在下文中一共展示了UIFont.Refresh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInspectorGUI
public override void OnInspectorGUI()
{
EditorGUIUtility.LookLikeControls(80f);
NGUIEditorTools.DrawSeparator();
mFont = target as UIFont;
ComponentSelector.Draw<UIAtlas>((UIAtlas)mFont.atlas, OnSelectAtlas);
if (mFont.atlas != null)
{
if (mFont.bmFont.isValid)
{
string spriteName = UISlicedSpriteInspector.SpriteField((UIAtlas)mFont.atlas, mFont.spriteName);
if (mFont.spriteName != spriteName)
{
NGUIEditorTools.RegisterUndo("Font Sprite", mFont);
mFont.spriteName = spriteName;
}
}
}
else
{
// No atlas specified -- set the material and texture rectangle directly
Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material;
if (mFont.material != mat)
{
NGUIEditorTools.RegisterUndo("Font Material", mFont);
mFont.material = mat;
}
}
bool resetWidthHeight = false;
if (mFont.atlas != null || mFont.material != null)
{
TextAsset data = EditorGUILayout.ObjectField("Import Font", null, typeof(TextAsset), false) as TextAsset;
if (data != null)
{
NGUIEditorTools.RegisterUndo("Import Font Data", mFont);
BMFontReader.Load(mFont.bmFont, NGUITools.GetHierarchy(mFont.gameObject), data.bytes);
mFont.Refresh();
resetWidthHeight = true;
Debug.Log("Imported " + mFont.bmFont.glyphCount + " characters");
}
}
if (mFont.bmFont.isValid)
{
Color green = new Color(0.4f, 1f, 0f, 1f);
Texture2D tex = mFont.texture;
if (tex != null)
{
if (mFont.atlas == null)
{
// Pixels are easier to work with than UVs
Rect pixels = NGUIMath.ConvertToPixels(mFont.uvRect, tex.width, tex.height, false);
// Automatically set the width and height of the rectangle to be the original font texture's dimensions
if (resetWidthHeight)
{
pixels.width = mFont.texWidth;
pixels.height = mFont.texHeight;
}
// Font sprite rectangle
GUI.backgroundColor = green;
pixels = EditorGUILayout.RectField("Pixel Rect", pixels);
GUI.backgroundColor = Color.white;
// Create a button that can make the coordinates pixel-perfect on click
GUILayout.BeginHorizontal();
{
GUILayout.Label("Correction", GUILayout.Width(75f));
Rect corrected = NGUIMath.MakePixelPerfect(pixels);
if (corrected == pixels)
{
GUI.color = Color.grey;
GUILayout.Button("Make Pixel-Perfect");
GUI.color = Color.white;
}
else if (GUILayout.Button("Make Pixel-Perfect"))
{
pixels = corrected;
GUI.changed = true;
}
}
GUILayout.EndHorizontal();
// Convert the pixel coordinates back to UV coordinates
Rect uvRect = NGUIMath.ConvertToTexCoords(pixels, tex.width, tex.height);
if (mFont.uvRect != uvRect)
{
//.........这里部分代码省略.........