本文整理汇总了C#中UIFont.MarkAsDirty方法的典型用法代码示例。如果您正苦于以下问题:C# UIFont.MarkAsDirty方法的具体用法?C# UIFont.MarkAsDirty怎么用?C# UIFont.MarkAsDirty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIFont
的用法示例。
在下文中一共展示了UIFont.MarkAsDirty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInspectorGUI
//.........这里部分代码省略.........
//if (mFont.bmFont.LegacyCheck())
//{
// Mogo.Util.LoggerHelper.Debug(mFont.name + " uses a legacy font data structure. Upgrading, please save.");
// EditorUtility.SetDirty(mFont);
//}
if (mFont.bmFont.isValid)
{
NGUIEditorTools.AdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false);
}
}
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.MarkAsDirty();
resetWidthHeight = true;
Mogo.Util.LoggerHelper.Debug("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();
{
示例2: OnInspectorGUI
//.........这里部分代码省略.........
ComponentSelector.Draw<UIAtlas>(mFont.atlas, OnSelectAtlas);
if (mFont.atlas != null)
{
if (mFont.bmFont.isValid)
{
NGUIEditorTools.AdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false);
}
EditorGUILayout.Space();
}
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;
}
}
// For updating the font's data when importing from an external source, such as the texture packer
bool resetWidthHeight = false;
if (mFont.atlas != null || mFont.material != null)
{
TextAsset data = EditorGUILayout.ObjectField("Import Data", 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.MarkAsDirty();
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();
{
示例3: OnInspectorGUI
public override void OnInspectorGUI()
{
mFont = target as UIFont;
EditorGUIUtility.LookLikeControls(80f);
NGUIEditorTools.DrawSeparator();
if (mFont.replacement != null)
{
mType = FontType.Reference;
mReplacement = mFont.replacement;
}
FontType after = (FontType)EditorGUILayout.EnumPopup("Font Type", mType);
if (mType != after)
{
if (after == FontType.Normal)
{
OnSelectFont(null);
}
else
{
mType = FontType.Reference;
}
}
if (mType == FontType.Reference)
{
ComponentSelector.Draw<UIFont>(mFont.replacement, OnSelectFont);
NGUIEditorTools.DrawSeparator();
GUILayout.Label("You can have one font simply point to\n" +
"another one. This is useful if you want to be\n" +
"able to quickly replace the contents of one\n" +
"font with another one, for example for\n" +
"swapping an SD font with an HD one, or\n" +
"replacing an English font with a Chinese\n" +
"one. All the labels referencing this font\n" +
"will update their references to the new one.");
if (mReplacement != mFont && mFont.replacement != mReplacement)
{
NGUIEditorTools.RegisterUndo("Font Change", mFont);
mFont.replacement = mReplacement;
UnityEditor.EditorUtility.SetDirty(mFont);
}
return;
}
NGUIEditorTools.DrawSeparator();
ComponentSelector.Draw<UIAtlas>(mFont.atlas, OnSelectAtlas);
if (mFont.atlas != null)
{
if (mFont.bmFont.LegacyCheck())
{
Debug.Log(mFont.name + " uses a legacy font data structure. Upgrading, please save.");
EditorUtility.SetDirty(mFont);
}
if (mFont.bmFont.isValid)
{
NGUIEditorTools.AdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false);
}
}
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.MarkAsDirty();
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)
//.........这里部分代码省略.........