本文整理汇总了C#中UIAtlas.MarkAsChanged方法的典型用法代码示例。如果您正苦于以下问题:C# UIAtlas.MarkAsChanged方法的具体用法?C# UIAtlas.MarkAsChanged怎么用?C# UIAtlas.MarkAsChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIAtlas
的用法示例。
在下文中一共展示了UIAtlas.MarkAsChanged方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateAtlas
/// <summary>
/// Update the sprite atlas, keeping only the sprites that are on the specified list.
/// </summary>
static public void UpdateAtlas (UIAtlas atlas, List<SpriteEntry> sprites)
{
if (sprites.Count > 0)
{
// Combine all sprites into a single texture and save it
if (UpdateTexture(atlas, sprites))
{
// Replace the sprites within the atlas
ReplaceSprites(atlas, sprites);
}
// Release the temporary textures
ReleaseSprites(sprites);
EditorUtility.ClearProgressBar();
return;
}
else
{
atlas.spriteList.Clear();
string path = NGUIEditorTools.GetSaveableTexturePath(atlas);
atlas.spriteMaterial.mainTexture = null;
if (!string.IsNullOrEmpty(path)) AssetDatabase.DeleteAsset(path);
}
atlas.MarkAsChanged();
Selection.activeGameObject = (NGUISettings.atlas != null) ? NGUISettings.atlas.gameObject : null;
EditorUtility.ClearProgressBar();
}
示例2: OnInspectorGUI
/// <summary>
/// Draw the inspector widget.
/// </summary>
public override void OnInspectorGUI ()
{
NGUIEditorTools.SetLabelWidth(80f);
mAtlas = target as UIAtlas;
UISpriteData sprite = (mAtlas != null) ? mAtlas.GetSprite(NGUISettings.selectedSprite) : null;
GUILayout.Space(6f);
if (mAtlas.replacement != null)
{
mType = AtlasType.Reference;
mReplacement = mAtlas.replacement;
}
GUILayout.BeginHorizontal();
AtlasType after = (AtlasType)EditorGUILayout.EnumPopup("Atlas Type", mType);
GUILayout.Space(18f);
GUILayout.EndHorizontal();
if (mType != after)
{
if (after == AtlasType.Normal)
{
mType = AtlasType.Normal;
OnSelectAtlas(null);
}
else
{
mType = AtlasType.Reference;
}
}
if (mType == AtlasType.Reference)
{
ComponentSelector.Draw<UIAtlas>(mAtlas.replacement, OnSelectAtlas, true);
GUILayout.Space(6f);
EditorGUILayout.HelpBox("You can have one atlas simply point to " +
"another one. This is useful if you want to be " +
"able to quickly replace the contents of one " +
"atlas with another one, for example for " +
"swapping an SD atlas with an HD one, or " +
"replacing an English atlas with a Chinese " +
"one. All the sprites referencing this atlas " +
"will update their references to the new one.", MessageType.Info);
if (mReplacement != mAtlas && mAtlas.replacement != mReplacement)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.replacement = mReplacement;
NGUITools.SetDirty(mAtlas);
}
return;
}
//GUILayout.Space(6f);
Material mat = EditorGUILayout.ObjectField("Material", mAtlas.spriteMaterial, typeof(Material), false) as Material;
if (mAtlas.spriteMaterial != mat)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.spriteMaterial = mat;
// Ensure that this atlas has valid import settings
if (mAtlas.texture != null) NGUIEditorTools.ImportTexture(mAtlas.texture, false, false, !mAtlas.premultipliedAlpha);
mAtlas.MarkAsChanged();
}
if (mat != null)
{
TextAsset ta = EditorGUILayout.ObjectField("TP Import", null, typeof(TextAsset), false) as TextAsset;
if (ta != null)
{
// Ensure that this atlas has valid import settings
if (mAtlas.texture != null) NGUIEditorTools.ImportTexture(mAtlas.texture, false, false, !mAtlas.premultipliedAlpha);
NGUIEditorTools.RegisterUndo("Import Sprites", mAtlas);
NGUIJson.LoadSpriteData(mAtlas, ta);
if (sprite != null) sprite = mAtlas.GetSprite(sprite.name);
mAtlas.MarkAsChanged();
}
float pixelSize = EditorGUILayout.FloatField("Pixel Size", mAtlas.pixelSize, GUILayout.Width(120f));
if (pixelSize != mAtlas.pixelSize)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.pixelSize = pixelSize;
}
}
if (mAtlas.spriteMaterial != null)
{
//.........这里部分代码省略.........
示例3: ReplaceSprites
/// <summary>
/// Replace the sprites within the atlas.
/// </summary>
static public void ReplaceSprites (UIAtlas atlas, List<SpriteEntry> sprites)
{
// Get the list of sprites we'll be updating
List<UISpriteData> spriteList = atlas.spriteList;
List<UISpriteData> kept = new List<UISpriteData>();
// Run through all the textures we added and add them as sprites to the atlas
for (int i = 0; i < sprites.Count; ++i)
{
SpriteEntry se = sprites[i];
UISpriteData sprite = AddSprite(spriteList, se);
kept.Add(sprite);
}
// Remove unused sprites
for (int i = spriteList.Count; i > 0; )
{
UISpriteData sp = spriteList[--i];
if (!kept.Contains(sp)) spriteList.RemoveAt(i);
}
// Sort the sprites so that they are alphabetical within the atlas
atlas.SortAlphabetically();
atlas.MarkAsChanged();
}