/// <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();
}