UIAtlasMaker.ReleaseSprites C# (CSharp) Method

ReleaseSprites() static private method

Release all temporary textures created for the sprites.
static private ReleaseSprites ( List sprites ) : void
sprites List
return void
    static void ReleaseSprites(List<SpriteEntry> sprites)
    {
        foreach (SpriteEntry se in sprites)
        {
            if (se.temporaryTexture)
            {
                NGUITools.Destroy(se.tex);
                se.tex = null;
            }
        }
        Resources.UnloadUnusedAssets();
    }

Usage Example

コード例 #1
0
    private static Texture2D UpdateUIAtlas(UIAtlas atlas, List <Texture2D> textures, ref int?size, out int minSize, UITexturePacker.FreeRectChoiceHeuristic heuristic)
    {
        Debug.Log("***************** Updating atlas " + atlas.name + " - " + DateTime.Now);
        Rect[]    texRects;
        Texture2D newTexture = CreateTexture(textures.ToArray(), ref size, 1, out texRects, out minSize, heuristic);
        List <UIAtlasMaker.SpriteEntry> sprites = UIAtlasMaker.CreateSprites(textures.Cast <Texture>().ToList());

        for (int i = 0; i < sprites.Count; i++)
        {
            Rect rect = NGUIMath.ConvertToPixels(texRects[i], newTexture.width, newTexture.height, true);

            UIAtlasMaker.SpriteEntry se = sprites[i];
            se.x      = Mathf.RoundToInt(rect.x);
            se.y      = Mathf.RoundToInt(rect.y);
            se.width  = Mathf.RoundToInt(rect.width);
            se.height = Mathf.RoundToInt(rect.height);
        }

        // Replace the sprites within the atlas
        UIAtlasMaker.ReplaceSprites(atlas, sprites);

        // Release the temporary textures
        UIAtlasMaker.ReleaseSprites(sprites);

        return(newTexture);
    }
All Usage Examples Of UIAtlasMaker::ReleaseSprites