- Modifié
Unity SkeletionAnimation has wrong UV mapping.
I'm basically following the steps from Søren Nielsen's "unity setup" tutorial ( https://www.youtube.com/watch?v=Cwfa5gDH0UI ), but using my own image assets and animation instead of Spine Boy. The images from the sprite sheet don't map correctly once I get everything into Unity.
In more detail, here are the steps I went through:
In Spine
- I created a basic walking animation using my own image assets. It looks fine when played inside of Spine.
- I exported sprite sheet, atlas txt and skeleton json into a subfolder of my Unity project assets.
In Unity
- I followed the steps to import runtimes into my project. No errors. Just the annoying namespace warning about "Animator" that I understand to be ignorable.
- I created the material, atlas, and skeleton data assets.
- I mapped sprite sheet, atlas txt, and skeleton data to the above assets, following Søren's steps.
- Created a new "Spine SkeletonAnimation" and mapped the SkeletonDataAsset to it.
Bam! I was happy to see something appear in the Scene window. The structure of the character's bones is represented by quads. I can play the animation. But the mapping of the texture to the quads is wrong. I tried changing the sprite sheet's Texture Type from "Sprite" to "Texture," but that doesn't fix it. I compared the sprite sheet image to the coords in the atlas txt, and they seem correct.
Any ideas how I can troubleshoot or fix this?
-Erik
Also, here is my sprite sheet so you can get the gist of what the parts showing in the scene are supposed to be. Just your basic arms, legs, etc. Original is 2048x2048. This one is 512x512 so the forum accepts it.
-Erik
Huh. Something changed and it sorta started working. I'm not sure what it was. But basically, I just came back to the Unity editor after doing some other stuff and hit play.
And now the quads show the correct body parts from the sprite sheet, but there is garbage showing in the transparent areas of the sprites.
Whether I set the sprite sheet's texture type to "sprite" or "texture" seems to make no difference. I also tried checking and unchecking the "Alpha is Transparency" check box under "skeleton Import Settings".
-Erik
Which version of unity are you running?
I'm actually redoing the video today so if you can send the unity project and files I will see if I can fix it and maybe a mention of whatever causes it would be good to have in the video.
Shiu a écritWhich version of unity are you running?
I'm actually redoing the video today so if you can send the unity project and files I will see if I can fix it and maybe mention a mention of whatever causes it would be good to have in the video.
Shiu,
This is 4.3.4f1 for Mac.
I zipped up the project files and am ready to send them, but the attachment size is too large. (About 6mb) If you let me know your email through here or PM, I can send you a download link.
Thank you for time in looking into it!
-Erik
You can mail it to contact@esotericsoftware.com just mention this thread in the mail. I'll take a look at it today
Took a look at your project files.
After re-exporting from Spine I got the wanted result
Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même
Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même
I'm really not sure what the problem could be, are you doing any editing on your atlas texture after exporting it?
The size of your art assets is pretty huge so you might want to set the scale even lower, maybe around 0.3 then it should fit in a single 1024 texture. In Unity you would then set the scale to 0.3 / 100 = 0.003 to convert to meters instead of pixels.
Okay, eventually, I caught up with you. My animation is clean and looking right in Unity. Thanks very much!
A few observations...
- Pressing "play" in Unity seems to do something to fix the very first issue with UV mapping wrong. In general, whenever I see the wrong parts appearing on SkeletonAnimation, it seems I can hit "play" and fix them. This has nothing to do with the second issue you troubleshot with opaque pixels.
- Reexporting from Spine slightly reduced the opaque pixels in the quads, but they were still there until I did the next step.
- Unchecking the "Alpha is transparency" in the image Import Settings (Unity) fully removed the opaque pixels. (clue for this came from looking at your screenshot above)
Then I went back to try to repro the part of the problem that seemed to be caused by the Spine export. Sigh... I couldn't do it. So the original cause is still a mystery to me.
But I'm happy my animation test works! Thank you very much, Søren.
-Erik
The size of your art assets is pretty huge so you might want to set the scale even lower, maybe around 0.3 then it should fit in a single 1024 texture.
That makes sense. But the larger size is important for what I'm doing. I want the camera to be able to zoom in on the face without it looking blocky.
-Erik
Sometimes things change in Unity and the runtime doesn't know it needs to reload some data. This is why sometimes pressing play "fixes" things. Silly Unity!