michalvadak
The easiest approach in your case is to export the skeleton three times, enabling the export flag only for the skin you want to export each time. This way, at runtime, your skeleton will require only the regions for the selected skin.
Next, use the texture packer separately, providing as input a folder containing only the attachments of that skin. For example, to create the atlas for skin1
, if your image folder is structured as follows:
You can create a temporary folder containing only skin1
:
Then, provide this temp/
folder to the standalone texture packer.
If there are shared elements across skins stored in a separate common/
folder:
- images/
- common/
- skin1/
- skin2/
- skin3/
Copy the common/
folder as well:
Make sure to select Combine subdirectories
so the texture packer doesn’t generate a separate atlas page for each folder.
Note that, as stated in the export flag documentation:
If a mesh attachment is not exported, none of its linked meshes will be exported either.
This means that if you export skin1
, and skin1
contains a linked mesh that references a mesh in skin2
, you must also export skin2
to preserve the dependency.
Alternatively, to overcome this limitation, you can export a JSON containing all the skins (or the skins for which there are dependencies). However, you’ll need to create a custom AttachmentLoader
that doesn’t throw an error when a region is missing from the atlas.
In this case, the custom AttachmentLoader
would function similarly to the AtlasAttachmentLoader
, but with the throw
declarations removed.
If you take this approach, ensure that at runtime, you only set skins that are present in your atlas to avoid errors.
You probably want to use CLI in this case to automatize this process.