JDBB When scaling an 8k image down to switch sizes I end up with a bad looking sprite, so I have come to the conclusion that I need to supply my own (manually authored) set of sprites at different scales. My sprites are made entirely using vector software (illustrator at the moment) so I have the option to just export sprites at different scales. When I do this I get much better results than letting unity auto scale them down (as expected).
Thanks for the clarification, this makes sense, automatic downsampling (via Unity's mipmap generation as well as via Spine Atlas Export Scale e.g. 0.5 or 0.25) will be inferior to that.
JDBB I have seen that I can use the spine texture packer to make a standalone atlas using my lower resolution sprites but I don't know if I could just swap the textures out as I don't think there is any guarantee that the
sprites will be packed into the same place in all the different atlases.
There is indeed no guarantee if you pack twice with different settings or resolutions.
JDBB I'm not sure if it is possible to swap the atlas itself out?
Yes, this is possible and perfectly valid. The AtlasAsset (and the referenced atlas.txt file) contains all the necessary information.
JDBB I want to be able to supply multiple sets of sprites that have been exported from illustrator at different scales.
By that I assume you mean that you want to author the attachment images for the Spine project in different resolutions, and then pack them to different sets of atlases, not sharing the same layout (see above).
JDBB I want to not have to load one set of textures then only after that load the correct set of textures as that would increase loading time.
If you have a different AtlasAsset for each resolution with different atlas layout, you unfortunately can't use the Spine Addressables Extension
on-demand loading module mentioned earlier, as this only replaces textures at materials and does not (yet) support different atlas layouts (i.e. does not support swapping out the atlas asset with a different one).
I assume this is not an option, but you could load a low-resolution atlas first (with little overhead) and then swap out the low-resolution atlas with the desired target resolution atlas.
If you need to avoid loading a low-resolution placeholder atlas asset first, you could programmatically at runtime load the SpineAtlasAsset
first and then construct the SkeletonDataAsset
, as described here:
https://esotericsoftware.com/spine-unity-main-components#Advanced-Instantiation-at-Runtime
Alternatively, you could write your own AttachmentLoader to customize loading, as described recently on this forum thread:
https://esotericsoftware.com/forum/d/26266-how-to-export-texture-just-for-one-skin-with-linked-mesh
JDBB Ideally I would also like to be able to not include the higher res textures when I build for the switch (not essential).
You could either always include just the lowest-resolution atlas, or download all atlas assets via addressables on-demand.
JDBB Ideally I would be able to swap the texture scale after the scene/prefab is already on screen (so that the game can adjust when the resolution changes, not essential).
You can swap out the atlas assets by assigning a different atlas asset at SkeletonDataAsset.atlasAssets
and then call skeletonDataAsset.Clear()
to clear the common loaded SkeletonData
. Then at all already loaded SkeletonAnimation
objects you would need to call skeletonAnimation.Initialize(true);
to reload and re-assign the proper skeleton data.
In general there are multiple ways to achieve your goal. I hope this hasn't raised more questions than it has answered. 🙂