public static void ExportSpriteToPNG(Sprite sprite, string filePath) { var texture = SpriteTool.Render(sprite); var data = texture.EncodeToPNG(); File.WriteAllBytes(filePath, data); }
private static void ExportSprites(IEnumerable <Sprite> sprites, string folder) { if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } foreach (var sprite in sprites) { var texture = SpriteTool.Render(sprite); var data = texture.EncodeToPNG(); var path = CreateUniqueFileName(folder, sprite.name, ".png"); File.WriteAllBytes(path, data); File.WriteAllLines(path + ".info", sprite.GetInfo()); } }