LuBu

Hey people! :)

In our project we use Spine character also in the UI (we also use masking) and we want to have multiple skins per character.
Since it is not possible for an UI SeketonGraphic to handle multipe textures (those skins need a lot of texture space).

How is it possible to put every skin one one texture so i can swap out the Materials together with the Skin?

Thaks in advance :)
User avatar
LuBu
Posts: 3

Pharan

Did you mean let each skin have its own texture?

If so, you can use Spine's Texture Packer... in the Spine menu.
If you put each skin's images in their own subfolder, the Texture Packer will pack each into their own atlas page. Each will be its own texture and material in Unity.

The downside of Texture Packer is if you have any images that weren't actually used in the skeleton, it'll pack them anyway, since it has no way of knowing what your skeleton was using.
User avatar
Pharan

Pharan
Posts: 4444

LuBu

Thanks fo the reply!

I tried the Texture Packer, but only the first skins texture is packed correctly. The following ones use a different layout, which looks on the skeleton like a messed up Jigsaw. Is there something im missing?
User avatar
LuBu
Posts: 3

Pharan

Oh, that's not how it works, unfortunately.
The packing layout won't be consistent across pages unless all your image sets are the same set (no extra or missing ones) and have the same dimensions.

For it to work, you would have to set skin, make sure the attachments from the new skin are used, and also switch the texture source (for UI).

It would be something like:
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
Note here that for SkeletonGraphic, the texture isn't applied every frame like in the regular component so you have to tell it which one to use. A lot of the weirdness in that regard comes from the base class we're inheriting from (UnityEngine.UI.MaskableGraphic).

The requirement to call Skeleton.SetSlotsToSetupPose, and AnimationState.Apply applies to both UI and non-UI versions. It has to do with some other theoretically flexible things you could do with skins.
User avatar
Pharan

Pharan
Posts: 4444


Return to Unity