• Unity
  • Multiple atlases on UI characters.

Related Discussions
...

Hello,

first of all, I know there are some other posts on this topic, but they are all quite old and I couldn't find a straightforward solution to this apparently popular issue. I also know that Spine inherits from UnityEngine.UI.MaskableGraphic to handle SkeletonGraphic (UI) but what I got, reading the older posts, is that there would be a workaround if I place each skin on different spritesheets. Is this true?
Would having a sheet with the base character and then separate sheets with costumes work?

I tried to follow the instructions user Erikari gave on this post:
http://zh.esotericsoftware.com/forum/Separated-atlas-for-each-skin-9835

But then I get missing regions in my SkeletonData. Maybe I'm doing something wrong.

Could anyone provide a step-by-step, up to date solution to this problem?

Thank you in advance.

Hi and welcome to Spine!

The above information still holds true - as long as all active attachments of the skeleton are using the same atlas texture, it will work with the single-material limitation. So if you switch between skins that all have a separate single texture, it will work. However, note that if you programmatically change an attachment at runtime so that one of second atlas texture is used, it will cause the same problems.

Regarding the export:
One important question: have you set the atlas extension to .atlas.txt? If it is the default .atlas, it will not be read by Unity.

It is potentially easiest to export the skeleton at once, with textures packed with setting Image Folder:

Prerequisites: Ensure there is a folder for each atlas texture that shall be created and that the attachment images are placed in the desired folders.

Step 1: Press Ctrl+E or in the dropdown menu select Export...
Step 2: Enable Texture Atlas Pack and select Image Folder instead of Attachments right to it.
Step 3: (optional) Check in Pack Settings if under Options in the bottom right Flatten Paths and Combine Subdirectories is disabled (this is the default).
Step 4: Click Export.

I have now added a section to the documentation pages here:
spine-unity Runtime Documentation: Advanced Export for SkeletonGraphic

Hello Harald, thank you very much for your reply and it's great that now this process is on the documentation as well.
So there's no way to switch skins at runtime this way? Not even doing something like this?

skeleton.SetSkin(myChosenSkin);
skeleton.SetSlotsToSetupPose(); // use the setup pose attachments based on the current skin.
skeletonGraphic.AnimationState.Apply(skeleton); // use the attachments based on the current animations.
skeletonGraphic.OverrideTexture = textureOfMyChosenSkin; // set the texture

By the way, I incidentally realized that setting the canvas as Screen Space - Camera, and moving the regular SkeletonAnimation slightly closer, it will indeed be rendered over UI and, if needed, another canvas can be layered on top to superimpose elements.
Moreover, if the SkeletonAnimation GameObject is parented to some UI, it will follow nicely.

This all might be obvious but might as well help people with the same issues in the future.

Thanks again.

You can switch skins at runtime on SkeletonGraphic - it's just the limitation of "each skin shall use only a single atlas texture". In general: all attachments of the currently active skin have to be contained in a single atlas. You can switch to a different skin as usual.

skeletonGraphic.OverrideTexture = textureOfMyChosenSki

No need to use OverrideTexture just to switch a skin, textures will be switched automatically depending on current attachments. Override shall be used only when really overriding it with something not already defined in the atlas description.