private static void ProcessAtlas(SVGBasicAtlas atlas) { Texture2D tmpTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false); List <SVGSpriteAssetFile> spritesAssets = atlas.SpriteAssets(); foreach (SVGSpriteAssetFile spriteAsset in spritesAssets) { SVGSpriteData spriteData = spriteAsset.SpriteData; Sprite original = spriteData.Sprite; // we must reference the original texture, because we want to keep the file reference (rd->texture.IsValid()) Sprite tmpSprite = Sprite.Create(original.texture, new Rect(0, 0, 1, 1), new Vector2(0, 0), SVGBasicAtlas.SPRITE_PIXELS_PER_UNIT, 0, SpriteMeshType.FullRect); // now we change the (sprite) asset content: actually we have just reduced its rectangle to a 1x1 pixel EditorUtility.CopySerialized(tmpSprite, original); } for (int i = 0; i < atlas.TextureAssetsCount(); i++) { AssetFile file = atlas.TextureAsset(i); Texture2D original = file.Object as Texture2D; // copy the 1x1 texture inside the original texture EditorUtility.CopySerialized(tmpTexture, original); } }
static private List <SVGSpriteAssetFile> GetSpritesList(SVGBasicAtlas atlas) { List <SVGSpriteAssetFile> spritesAssets = atlas.SpriteAssets(); spritesAssets.Sort(delegate(SVGSpriteAssetFile spriteAsset1, SVGSpriteAssetFile spriteAsset2) { Sprite sprite1 = spriteAsset1.SpriteData.Sprite; Sprite sprite2 = spriteAsset2.SpriteData.Sprite; return(string.Compare(sprite1.name, sprite2.name, StringComparison.OrdinalIgnoreCase)); }); return(spritesAssets); }