示例#1
0
    /// <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);
        }
    }
示例#2
0
    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();
    }
示例#3
0
    /// <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);
    }