本文整理汇总了C#中UIAtlas.MarkAsDirty方法的典型用法代码示例。如果您正苦于以下问题:C# UIAtlas.MarkAsDirty方法的具体用法?C# UIAtlas.MarkAsDirty怎么用?C# UIAtlas.MarkAsDirty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIAtlas
的用法示例。
在下文中一共展示了UIAtlas.MarkAsDirty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateAtlas
/// <summary>
/// Update the sprite atlas, keeping only the sprites that are on the specified list.
/// </summary>
static void UpdateAtlas (UIAtlas atlas, List<SpriteEntry> sprites)
{
if (sprites.Count > 0)
{
// Combine all sprites into a single texture and save it
UpdateTexture(atlas, sprites);
// Replace the sprites within the atlas
ReplaceSprites(atlas, sprites);
// Release the temporary textures
ReleaseSprites(sprites);
}
else
{
atlas.spriteList.Clear();
string path = NGUIEditorTools.GetSaveableTexturePath(atlas);
atlas.spriteMaterial.mainTexture = null;
if (!string.IsNullOrEmpty(path)) AssetDatabase.DeleteAsset(path);
}
atlas.MarkAsDirty();
EditorUtility.DisplayDialog("Atlas Changed", "The atlas has been updated. Don't forget to save the scene to write the changes!", "OK");
}
示例2: OnInspectorGUI
/// <summary>
/// Draw the inspector widget.
/// </summary>
public override void OnInspectorGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
mAtlas = target as UIAtlas;
UIAtlas.Sprite sprite = (mAtlas != null) ? mAtlas.GetSprite(NGUISettings.selectedSprite) : null;
NGUIEditorTools.DrawSeparator();
if (mAtlas.replacement != null)
{
mType = AtlasType.Reference;
mReplacement = mAtlas.replacement;
}
AtlasType after = (AtlasType)EditorGUILayout.EnumPopup("Atlas Type", mType);
if (mType != after)
{
if (after == AtlasType.Normal)
{
OnSelectAtlas(null);
}
else
{
mType = AtlasType.Reference;
}
}
if (mType == AtlasType.Reference)
{
ComponentSelector.Draw<UIAtlas>(mAtlas.replacement, OnSelectAtlas);
NGUIEditorTools.DrawSeparator();
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;
UnityEditor.EditorUtility.SetDirty(mAtlas);
}
return;
}
if (!mConfirmDelete)
{
NGUIEditorTools.DrawSeparator();
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.MarkAsDirty();
mConfirmDelete = false;
}
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);
NGUIEditorTools.RegisterUndo("Import Sprites", mAtlas);
NGUIJson.LoadSpriteData(mAtlas, ta);
if (sprite != null) sprite = mAtlas.GetSprite(sprite.name);
mAtlas.MarkAsDirty();
}
UIAtlas.Coordinates coords = (UIAtlas.Coordinates)EditorGUILayout.EnumPopup("Coordinates", mAtlas.coordinates);
if (coords != mAtlas.coordinates)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.coordinates = coords;
mConfirmDelete = false;
}
float pixelSize = EditorGUILayout.FloatField("Pixel Size", mAtlas.pixelSize, GUILayout.Width(120f));
if (pixelSize != mAtlas.pixelSize)
//.........这里部分代码省略.........
示例3: ReplaceSprites
/// <summary>
/// Replace the sprites within the atlas.
/// </summary>
static void ReplaceSprites (UIAtlas atlas, List<SpriteEntry> sprites)
{
// Get the list of sprites we'll be updating
List<UIAtlas.Sprite> spriteList = atlas.spriteList;
List<UIAtlas.Sprite> kept = new List<UIAtlas.Sprite>();
// The atlas must be in pixels
atlas.coordinates = UIAtlas.Coordinates.Pixels;
// 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];
UIAtlas.Sprite sprite = AddSprite(spriteList, se);
kept.Add(sprite);
}
// Remove unused sprites
for (int i = spriteList.Count; i > 0; )
{
UIAtlas.Sprite sp = spriteList[--i];
if (!kept.Contains(sp)) spriteList.RemoveAt(i);
}
atlas.MarkAsDirty();
}
示例4: 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);
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;
UnityEditor.EditorUtility.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.MarkAsDirty();
}
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.MarkAsDirty();
}
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)
{
Color blue = new Color(0f, 0.7f, 1f, 1f);
//.........这里部分代码省略.........
示例5: OnInspectorGUI
/// <summary>
/// Draw the inspector widget.
/// </summary>
public override void OnInspectorGUI()
{
EditorGUIUtility.LookLikeControls(80f);
mAtlas = target as UIAtlas;
NGUIEditorTools.DrawSeparator();
if (mAtlas.replacement != null)
{
mType = AtlasType.Reference;
mReplacement = mAtlas.replacement;
}
AtlasType after = (AtlasType)EditorGUILayout.EnumPopup("Atlas Type", mType);
if (mType != after)
{
if (after == AtlasType.Normal)
{
OnSelectAtlas(null);
}
else
{
mType = AtlasType.Reference;
}
}
if (mType == AtlasType.Reference)
{
ComponentSelector.Draw<UIAtlas>(mAtlas.replacement, OnSelectAtlas);
NGUIEditorTools.DrawSeparator();
GUILayout.Label("You can have one atlas simply point to\n" +
"another one. This is useful if you want to be\n" +
"able to quickly replace the contents of one\n" +
"atlas with another one, for example for\n" +
"swapping an SD atlas with an HD one, or\n" +
"replacing an English atlas with a Chinese\n" +
"one. All the sprites referencing this atlas\n" +
"will update their references to the new one.");
if (mReplacement != mAtlas && mAtlas.replacement != mReplacement)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.replacement = mReplacement;
UnityEditor.EditorUtility.SetDirty(mAtlas);
}
return;
}
if (!mConfirmDelete)
{
NGUIEditorTools.DrawSeparator();
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.MarkAsDirty();
mConfirmDelete = false;
}
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);
NGUIEditorTools.RegisterUndo("Import Sprites", mAtlas);
NGUIJson.LoadSpriteData(mAtlas, ta);
if (mSprite != null) mSprite = mAtlas.GetSprite(mSprite.name);
mAtlas.MarkAsDirty();
}
UIAtlas.Coordinates coords = (UIAtlas.Coordinates)EditorGUILayout.EnumPopup("Coordinates", mAtlas.coordinates);
if (coords != mAtlas.coordinates)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.coordinates = coords;
mConfirmDelete = false;
}
float pixelSize = EditorGUILayout.FloatField("Pixel Size", mAtlas.pixelSize);
if (pixelSize != mAtlas.pixelSize)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.pixelSize = pixelSize;
//.........这里部分代码省略.........
示例6: UpdateAtlas
/// <summary>
/// Update the sprite atlas, keeping only the sprites that are on the specified list.
/// </summary>
static 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);
return;
}
else
{
atlas.spriteList.Clear();
string path = NGUIEditorTools.GetSaveableTexturePath(atlas);
atlas.spriteMaterial.mainTexture = null;
if (!string.IsNullOrEmpty(path)) AssetDatabase.DeleteAsset(path);
}
atlas.MarkAsDirty();
Selection.activeGameObject = (NGUISettings.atlas != null) ? NGUISettings.atlas.gameObject : null;
}
示例7: ReplaceSprites
/// <summary>
/// Replace the sprites within the atlas.
/// </summary>
static 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.MarkAsDirty();
}
示例8: OnInspectorGUI
/// <summary>
/// Draw the inspector widget.
/// </summary>
public override void OnInspectorGUI()
{
mRegisteredUndo = false;
EditorGUIUtility.LookLikeControls(80f);
mAtlas = target as UIAtlas;
if (!mConfirmDelete)
{
NGUIEditorTools.DrawSeparator();
Material mat = EditorGUILayout.ObjectField("Material", mAtlas.material, typeof(Material), false) as Material;
if (mAtlas.material != mat)
{
RegisterUndo();
mAtlas.material = mat;
// Ensure that this atlas has valid import settings
if (mAtlas.texture != null) NGUIEditorTools.ImportTexture(mAtlas.texture, false, false);
mAtlas.MarkAsDirty();
mConfirmDelete = false;
}
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);
Undo.RegisterUndo(mAtlas, "Import Sprites");
NGUIJson.LoadSpriteData(mAtlas, ta);
mRegisteredUndo = true;
if (mSprite != null) mSprite = mAtlas.GetSprite(mSprite.name);
mAtlas.MarkAsDirty();
}
UIAtlas.Coordinates coords = (UIAtlas.Coordinates)EditorGUILayout.EnumPopup("Coordinates", mAtlas.coordinates);
if (coords != mAtlas.coordinates)
{
RegisterUndo();
mAtlas.coordinates = coords;
mConfirmDelete = false;
}
}
}
if (mAtlas.material != null)
{
Color blue = new Color(0f, 0.7f, 1f, 1f);
Color green = new Color(0.4f, 1f, 0f, 1f);
if (mSprite == null && mAtlas.sprites.Count > 0)
{
mSprite = mAtlas.sprites[0];
}
if (mConfirmDelete)
{
if (mSprite != null)
{
// Show the confirmation dialog
NGUIEditorTools.DrawSeparator();
GUILayout.Label("Are you sure you want to delete '" + mSprite.name + "'?");
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
{
GUI.backgroundColor = Color.green;
if (GUILayout.Button("Cancel")) mConfirmDelete = false;
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Delete"))
{
RegisterUndo();
mAtlas.sprites.Remove(mSprite);
mConfirmDelete = false;
}
GUI.backgroundColor = Color.white;
}
GUILayout.EndHorizontal();
}
else mConfirmDelete = false;
}
else
{
GUI.backgroundColor = Color.green;
GUILayout.BeginHorizontal();
{
EditorGUILayout.PrefixLabel("Add/Delete");
if (GUILayout.Button("New Sprite"))
{
//.........这里部分代码省略.........