Hi and welcome to Spine! 🙂
Do you want to display the complete atlas texture as you see it in the Project panel? If so, then you can use normal means to either change the Texture Type
in the Texture Importer settings to Sprite (2D and UI)
and set the Sprite Mode
to e.g. Single
. Then you can assign the sprite at a SpriteRenderer
as usual. Please note that by default, Spine will pack your Attachments to atlas pages independently from which Skin they are used by. So you could have e.g. five skins and all attachments fit on two atlas pages.
If you don't need it to be a Sprite
specifically, you can also assign the Material for the desired atlas texture page at a Quad object. Note however that the size of the quad will not be adjusted automatically if it's a non-square atlas texture (like 512x256).
If you want to iterate over all atlas pages (not only actively used pages, which you could get via meshRenderer.Materials
), you can use the following code:
AtlasAssetBase[] atlasAssets = skeletonAnimation.SkeletonDataAsset.atlasAssets;
for (int i = 0; i < atlasAssets.Length; ++i) {
foreach (Material material in atlasAssets[i].Materials) {
if (material.mainTexture != null) {
// assign material.mainTexture at your desired object
}
}
}
You could either change the texture at an existing Sprite
(which is used at your SpriteRenderer
) or create a new Sprite
from the given atlas texture.
If you want to only show attachments that are currently active (attachments of a specific single skin) and want to display them layed out in a grid or line next to each other, I'm afraid this will involve some coding on your side. If that's what you want, please let us know, then we can provide some information on how you could achieve that.