Created
November 1, 2021 15:17
-
-
Save gsteigert/b65e1c4c47df2f65d2d7296341e3f5b0 to your computer and use it in GitHub Desktop.
An Aseprite script to ease exporting a bunch of layers and groups into packed sprite sheets (a.k.a. texture atlases).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This script will: | |
-- (1) Flatten each group into a layer; | |
-- (2) Invoke the 'export sprite sheet' command; | |
-- (3) Undo the changes. | |
-- | |
-- v1.0: Initial version. | |
-- | |
-- Ref: https://github.com/aseprite/aseprite/blob/main/src/app/commands/cmd_export_sprite_sheet.cpp | |
local spr = app.activeSprite | |
if not spr then | |
return app.alert "You should have an sprite opened" | |
end | |
local function exportGroups() | |
app.transaction(function() | |
for i,layer in ipairs(spr.layers) do | |
if layer.isGroup then | |
local name = layer.name | |
app.range.layers = { layer } | |
app.command.FlattenLayers(false) | |
spr.layers[i].name = name | |
end | |
end | |
end) | |
app.command.ExportSpriteSheet { | |
splitLayers=true, | |
} | |
app.undo() | |
end | |
exportGroups() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment