• Unity
  • Settings For Spine Animations In Unity

Related Discussions
...

Good Evening All, 🙂

I'm importing my Spine Animations to Unity now and I have two quick questions:

1. I noticed that my imported skeleton's scale was set to .01. I checked the Auto-Import settings and noticed the Default SkeletonData Scale is set to .01. Is this intended for the correct dimensions and is there a reason its not set to 1? :think:

2. I noticed that adjusting the Pixels Per Unit and the texture is not changing the characters size at all. Is intended?
My projects PPU is 256 for everything so its uniform and organized. Is there anything I can do to match the rest of my project?

Thanks! 8)

Hi,

1. I noticed that my imported skeleton's scale was set to .01. I checked the Auto-Import settings and noticed the Default SkeletonData Scale is set to .01. Is this intended for the correct dimensions and is there a reason its not set to 1? :think:

The default scale value is correct because the unit in Unity is meter. You can find more detailed information about this in the post below:
为什么我们制作的sipne导入unity要缩放0.01后才是正常大小?

2. I noticed that adjusting the Pixels Per Unit and the texture is not changing the characters size at all. Is intended?
My projects PPU is 256 for everything so its uniform and organized. Is there anything I can do to match the rest of my project?

Please enter your SkeletonData Scale values as 1/PixelPerUnit. So in your case 1/256 = 0.00390625.
You can setup the default SkeletonData Scale in Spine Preferences, accessible via Edit - Preferences (Unity - Preferences on Mac):
spine-unity Runtime Documentation: Spine Preferences

Misaki wrote

Hi,

1. I noticed that my imported skeleton's scale was set to .01. I checked the Auto-Import settings and noticed the Default SkeletonData Scale is set to .01. Is this intended for the correct dimensions and is there a reason its not set to 1? :think:

The default scale value is correct because the unit in Unity is meter. You can find more detailed information about this in the post below:
为什么我们制作的sipne导入unity要缩放0.01后才是正常大小?

2. I noticed that adjusting the Pixels Per Unit and the texture is not changing the characters size at all. Is intended?
My projects PPU is 256 for everything so its uniform and organized. Is there anything I can do to match the rest of my project?

Please enter your SkeletonData Scale values as 1/PixelPerUnit. So in your case 1/256 = 0.00390625.
You can setup the default SkeletonData Scale in Spine Preferences, accessible via Edit - Preferences (Unity - Preferences on Mac):
spine-unity Runtime Documentation: Spine Preferences

That answers both questions perfectly. Thank you Misaki!! 🙂

I'm glad to hear that! Thank you for getting back to us 🙂

Actually, I take it back, I'm confused. :think:

The sizes are not accurate on my end. I imported my 1024 x 1024 Spine animation and my 256 x 256 Spine animation to compare.

When I make both of their textures 256 PPU, and change both of their skeletons scales
( 1/256 = 0.00390625 & 1/1024 = .0009765625), this is what I see:

My smaller resolution is way bigger than my higher resolution.

When I make both PPU 256 and make both of their scale .01, the size is identical? If I make both of their PPU the same then they should scale relatively.

Why is my 1,024 x 1,024 not 4x bigger then my 256 x 256 with the same scaling settings?
How do I correct this?

Sorry, my previous answer missed the below point of your question:

I noticed that adjusting the Pixels Per Unit and the texture is not changing the characters size at all. Is intended?

If the texture scale setting of the texture packer does not change the size of the skeleton, because it is just to adjust the size of the texture atlas pages.
If you would like to work with high-resolution textures in the Spine editor and then make the both texture and skeleton smaller in-game, either reduce the scale of the skeleton's root bone before exporting or reduce the scale of the skeleton GameObject in Unity.

Misaki wrote

Sorry, my previous answer missed the below point of your question:

I noticed that adjusting the Pixels Per Unit and the texture is not changing the characters size at all. Is intended?

If the texture scale setting of the texture packer does not change the size of the skeleton, because it is just to adjust the size of the texture atlas pages.
If you would like to work with high-resolution textures in the Spine editor and then make the both texture and skeleton smaller in-game, either reduce the scale of the skeleton's root bone before exporting or reduce the scale of the skeleton GameObject in Unity.

Sorry, I didn't quite understand that. 🙁

I will try and ask my question more simply:
My game uses 256 PPU. How can I make my Spine Animations all the correct size in Unity?
(example: I have an existing 512x512 texture in Unity. The 1024x1024 Spine Animation should be 2x the size)

Thanks!

You have two texture sizes for the same skeleton, right?
Texture size does not change the skeleton size, so if you want the skeleton to appear at twice the size, change the skeleton GameObject's scale to twice the size.

The two characters on the left are old images I imported. They are not Spine related. Their PPU is 256.

The two on the right are imported Spine animations with default settings. 100 PPU & .01 Skeleton Scale.

Please tell me the settings I need to use so the Spine Animations are the same sizes as the images on the left.

It depends on how you originally created your Spine skeleton, there it's defined as 1unit = 1px (before any scaling), it does not change if you later modify the texture size of the atlas texture after it has been exported.

Let's assume you originally created your skeleton with attachments of the size that was packed to a 1024x1024 atlas texture after export, with e.g. a head attachment image of the size 100x100 px. When you drag-and-drop your 100x100 image into the Spine Editor viewport to create a bone with an attachment, (and it's a child of the root bone), then the rectangle mesh that holds the head image will be of size 100x100 units in Spine. If you don't scale any of the bones and attachments and export the skeleton normally, you will end up with 1 px being equal to 1 unit, which is saved in the skeleton .json or .skel.bytes file. Now you can modify the texture as you like, e.g. open it in an image editor and downscale it to quarter size, this will not modify the skeleton data that is contained in the .json file, the rectangle mesh of the attachment is still 100x100 units.

In other words, think of it more like a 3D model: you have created the mesh geometry once and mapped a texture to it, now the mesh geometry scale matters, not the resolution of your texture. Note that size can later no longer be derived reasonably from the attachment image size, since you can scale and distort your attachments and bones as you like, or use multiple atlas textures that have been downscaled differently.

Importing in Unity now provides an import skeleton scale factor to scale the 100x100 units rectangle (which were created by a 100x100 pixels image) so that you don't end up with 100 units for the original 100 pixels (scale of 1). If you now want the PPU (pixels per unit) to be 256, you can set the import skeleton scale to 1 / PPU = 1 / 256 since it's the inverse of PPU, units per pixel. This will make your 100x100 units become 100 / 256 x 100 / 256 units in your Unity scene, which is the same as if you drag & drop a 100x100px image into the Unity scene at 256 PPU.

To answer your question: if you have originally created your skeleton with attachments that led to the 1024x1024 atlas (without any texture scale of e.g. 0.5 upon export), then this skeleton should be imported with import scale 1 / 256 for 256 PPU. If you have a second copy of the skeleton data asset for quarter size with a downscaled texture of 256x256 that uses the same unmodified skeleton .json file (created for the 1024x1024 size), you need to multiply the import scale for that skeleton data asset by a further 1/4 to match the quarter texture size, which will be 1/256/4 = 1/1024.

If you have just a single SkeletonDataAsset, set the import scale to 1/256 and set the GameObject scale of any instance that uses the 1/4 downscaled texture to scale 1/4.

Harald wrote

It depends on how you originally created your Spine skeleton, there it's defined as 1unit = 1px (before any scaling), it does not change if you later modify the texture size of the atlas texture after it has been exported.

Let's assume you originally created your skeleton with attachments of the size that was packed to a 1024x1024 atlas texture after export, with e.g. a head attachment image of the size 100x100 px. When you drag-and-drop your 100x100 image into the Spine Editor viewport to create a bone with an attachment, (and it's a child of the root bone), then the rectangle mesh that holds the head image will be of size 100x100 units in Spine. If you don't scale any of the bones and attachments and export the skeleton normally, you will end up with 1 px being equal to 1 unit, which is saved in the skeleton .json or .skel.bytes file. Now you can modify the texture as you like, e.g. open it in an image editor and downscale it to quarter size, this will not modify the skeleton data that is contained in the .json file, the rectangle mesh of the attachment is still 100x100 units.

In other words, think of it more like a 3D model: you have created the mesh geometry once and mapped a texture to it, now the mesh geometry scale matters, not the resolution of your texture. Note that size can later no longer be derived reasonably from the attachment image size, since you can scale and distort your attachments and bones as you like, or use multiple atlas textures that have been downscaled differently.

Importing in Unity now provides an import skeleton scale factor to scale the 100x100 units rectangle (which were created by a 100x100 pixels image) so that you don't end up with 100 units for the original 100 pixels (scale of 1). If you now want the PPU (pixels per unit) to be 256, you can set the import skeleton scale to 1 / PPU = 1 / 256 since it's the inverse of PPU, units per pixel. This will make your 100x100 units become 100 / 256 x 100 / 256 units in your Unity scene, which is the same as if you drag & drop a 100x100px image into the Unity scene at 256 PPU.

To answer your question: if you have originally created your skeleton with attachments that led to the 1024x1024 atlas (without any texture scale of e.g. 0.5 upon export), then this skeleton should be imported with import scale 1 / 256 for 256 PPU. If you have a second copy of the skeleton data asset for quarter size with a downscaled texture of 256x256 that uses the same unmodified skeleton .json file (created for the 1024x1024 size), you need to multiply the import scale for that skeleton data asset by a further 1/4 to match the quarter texture size, which will be 1/256/4 = 1/1024.

If you have just a single SkeletonDataAsset, set the import scale to 1/256 and set the GameObject scale of any instance that uses the 1/4 downscaled texture to scale 1/4.

Thanks for that detailed writeup, Harald!