- Editado
3.8 -> 4.0 upgrade guide? My issues and solutions below..
I upgraded the runtime to 4.0, as exporting the skin from 4.0 to 3.8 gave some weird issues with the images being cut off. And now i'm having these errors in these lines of code:
This line is not working in the new runtime's sample codes either, so something changed.
Assets/_Game/Scripts/BlueGoo/Animation/Gunman/WeaponMixAndMatch.cs(85,40): error CS1061: 'Skeleton' does not contain a definition for 'UnshareSkin' and no accessible extension method 'UnshareSkin' accepting a first argument of type 'Skeleton' could be found (are you missing a using directive or an assembly reference?)
customSkin = customSkin ?? skeleton.UnshareSkin(true, false, skeletonAnimation.AnimationState); // use this if you are not customizing on the default skin.
Temp solution: Use this code instead, but i'm not sure if I will get any trouble.
customSkin = customSkin ?? new Skin("custom skin"); // This requires that all customizations are done with skin placeholders defined in Spine.
The second issue is this:
Assets/_Game/Scripts/BlueGoo/Animation/Gunman/WeaponMixAndMatch.cs(155,18): error CS1061: 'Skin' does not contain a definition for 'AddAttachments' and no accessible extension method 'AddAttachments' accepting a first argument of type 'Skin' could be found (are you missing a using directive or an assembly reference?)
var repackedSkin = new Skin("repacked skin");
repackedSkin.AddAttachments(skeleton.Data.DefaultSkin); // Include the "default" skin. (everything outside of skin placeholders)
Solution: Change AddAttachments to AddSkin.
Anything tips for me here?
After reexporting my main character (which is based on the gunman, but heavily modified) this happened.
The animation seems to play for a little while, then the legs disappear. At one point the shoes also disappear.
I'm switching between two skins of the character, once for each play of the game, but it seems to be the same thing.
It might be related to the custom skin thing i mentioned above, but I can send you the spine-file in private if you wanna have a look.
Thanks!
nicmar escribióThis line is not working in the new runtime's sample codes either, so something changed.
Solution: Change AddAttachments to AddSkin.
Anything tips for me here?
Regarding the runtime samples: the two commented-out line should have been removed when the API cleanup was done, we missed to remove these lines, thanks for the hint! It will be removed in the next published package.
In general, any breaking changes are always documented in the Changelog.md file:
https://github.com/EsotericSoftware/spine-runtimes/blob/4.0-beta/CHANGELOG.md#unity
Here the relevant first entry reads:
changelog.md - section 4.0 - Unity escribió- Removed all
Spine.Unity.AttachmentTools.SkinUtilities
Skin extension methods. These have become obsoleted and error-prone since the introduction of the new Skin API in 3.8. To fix any compile errors, replace any usage of Skin extension methods with their counterparts, e.g. replace occurrances ofskin.AddAttachments()
withskin.AddSkin()
.
Basically your replacements look fine and there should not be any problems, so the question is why you are encountering the problem as you have described below:
nicmar escribióAfter reexporting my main character (which is based on the gunman, but heavily modified) this happened.
The animation seems to play for a little while, then the legs disappear. At one point the shoes also disappear.I'm switching between two skins of the character, once for each play of the game, but it seems to be the same thing.
It might be related to the custom skin thing i mentioned above, but I can send you the spine-file in private if you wanna have a look.
If you could condense the problem down to a minimal Unity project that still shows the problem, we are happy to have a look at it, please send us the project as zip package to contact@esotericsoftware.com.
I believe there is only one gotcha in the Spine editor when moving from 3.8 to 4.0: In 3.8, a constraint may revert the changes made by another constraint. In 4.0, that doesn't happen. That is great because it means in 4.0 you can do more with constraints, but if your project happened to rely on the behavior in 3.8, then when you move to 4.0 you may have a constraint affecting your bones unexpectedly.
It's just a guess, but that may be why your legs disappear.
Thanks for the ideas, I was trying to make a minimal unity project, but there are so many dependancies and combinations of scripts that makes it hard to do that. So I'm gonna try and find the root of the problem in the main project instead.
I can't remember I'm using constraints regarding the legs in Spine, but I'll try to take it one step at a time to see where the problem lies.
I'll be back.
I've been banging my head for several hours on this, without a solution, so now I'm back to the second of the 2 code changes i mentioned:
I'm currently using this code:
// Make a new skin without head and hair
customSkin = customSkin ?? new Skin("custom skin"); // This requires that all customizations are done with skin placeholders defined in Spine.
I'm not doing skin placeholders in Spine as far as I know.
This is the old code, which had that comment from your code, and I am NOT customizing on the default skin:
//customSkin = customSkin ?? skeleton.UnshareSkin(true, false, skeletonAnimation.AnimationState); // use this if you are not customizing on the default skin.
So what is the correct code to "UnshareSkin" in 4.0? I just noticed when I select the Default skin, everything but the arms go away, so it's very likely this is the issue..
Thanks!
My guess is it's related to this comment in the change log "Removed all Spine.Unity.AttachmentTools.SkinUtilities Skin extension methods. These have become obsoleted and error-prone since the introduction of the new Skin API in 3.8. To fix any compile errors, replace any usage of Skin extension methods with their counterparts, e.g. replace occurrances of skin.AddAttachments() with skin.AddSkin()."
So do I need to update my rig from the Spine editor, if so, how?
Is there a new version of the Mix and match that works when I have two skins in Spine and not using the default skin?
So if I deselect skins in the editor, this is what I get, and it seems to be the same exact thing that are left after moving around the character, and the same as "default" skin in Unity. So I'm 99% it's related to skins and the "UnshareSkin" feature not being available.
How can I solve this, as I want to base the new skin on either the Boy or girl Skin, then I replace the attachment in the weapon slots with the images being loaded from Unity.
Another solution might be to copy the ”boy” skin to the default. Can you do that, and would that work, or would that use the boy’s attachments when doing the mix and match for the weapons using the ”girl” skin?
Sorry to hear that your issue still persists!
nicmar escribióSo what is the correct code to "UnshareSkin" in 4.0? I just noticed when I select the Default skin, everything but the arms go away, so it's very likely this is the issue..
This is the previous code of UnshareSkin()
:
https://github.com/EsotericSoftware/spine-runtimes/blob/3.8/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/SkinUtilities.cs#L41-L53
https://github.com/EsotericSoftware/spine-runtimes/blob/878c862af40e564665ded4ba116adae12a79f091/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/SkinUtilities.cs#L56
Did you perhaps not call skeleton.SetSlotsToSetupPose();
and skeletonAnimation.Update(0);
?
nicmar escribióIs there a new version of the Mix and match that works when I have two skins in Spine and not using the default skin?
The more actual workflow on combining multiple skins is shown in the Mix and Match Skins
example scene.
nicmar escribióI'm not doing skin placeholders in Spine as far as I know.
Do you mean you are not using Skin placeholders in the Spine project? I can see some skin placeholder "coat hangers" in your screenshot though. However, if you have some attachments assigned without using a skin placeholder (such as e.g. multiple mouth expression attachments would be assigned and switched via animation), an animation might accidentally have an attachment keyframe set that switches your attachment unintentionally.
You could send us your problematic Spine project (including the image assets), as a zip package to contact@esotericsoftware,com then we can have a look at what's going wrong.
Yay, it worked, thanks a lot!
The MixAndMatchSkinsExample script let me in the right way. The only thing I needed was:
customSkin.AddSkin(skeletonAnimation.Skeleton.Skin);
So I guess it adds the current skin, before adding the customizations.
I also had SetSlotsToSetupPose commented out but it didn't make a difference, but I'll set it just in case. Finally I can make the move to 4.0!
Awesome, glad you've figured it out! Thanks for letting us know!
I have just created an official counterpart to this forum thread here:
Spine-Unity 3.8 to 4.0 Upgrade Guide
Let's please keep any follow-up discussions to the offial guide from now on to prevent spreading the topic across too many threads.
As always, any input is greatly welcome on the official thread of course!