/// <summary> /// 释放加载进来的精灵(IAssetRequest.Dispose()) /// </summary> /// <param name="sprites"></param> private void ReleaseSprite(DynamicAtlas.SpriteEntry sprites) { sprites.Clear(); IAssetRequest assetRequest = null; if (this.m_dicAssetRequestTexture.TryGetValue(sprites.spriteName, out assetRequest)) { assetRequest.Dispose(); this.m_dicAssetRequestTexture.Remove(sprites.spriteName); } }
private void ReplaceSprites(UIAtlas atlas, List <DynamicAtlas.SpriteEntry> sprites) { List <UISpriteData> spriteList = atlas.spriteList; List <UISpriteData> list = new List <UISpriteData>(); for (int i = 0; i < sprites.Count; i++) { DynamicAtlas.SpriteEntry se = sprites[i]; UISpriteData item = this.AddSprite(spriteList, se); list.Add(item); } int count = spriteList.Count; while (count > 0) { UISpriteData spriteData = spriteList[--count]; if (list.Contains(spriteData)) { spriteList.RemoveAt(count); } } atlas.MarkAsChanged(); }
/// <summary> /// 添加精灵到图集里面 /// </summary> /// <param name="sprites"></param> /// <param name="se"></param> /// <returns></returns> private UISpriteData AddSprite(List <UISpriteData> sprites, DynamicAtlas.SpriteEntry se) { UISpriteData sprite = null; foreach (var current in sprites) { if (current.name == se.tex.name) { sprite = current; break; } } if (sprite != null) { sprite.CopyFrom(se); } else { sprite = new UISpriteData(); sprite.CopyFrom(se); sprites.Add(sprite); } return(sprite); }