• Unity
  • Spine-Unity 3.7 to 3.8 Upgrade Guide

Related Discussions
...

Re-export your skeleton data
Note: Json and binary skeleton data files exported from Spine 3.7 will not be readable by the Spine-Unity 3.8 runtime!
The skeleton data files need to be re-exported using Spine 3.8.

If you have many projects, we suggest automating exporting your project files:
Export - Spine User Guide: Command line
For example, here is a script we use to export all the Spine example projects and to create texture atlases:
spine-runtimes/export.sh at 3.8

Recommended upgrade steps for upgrading from 3.7 to 3.8:

  1. Create a backup of your 3.7 project to be on the safe side.

  2. Close all open scenes and create a new blank scene, and have nothing selected. This is to make sure there are no active Spine objects.

  3. Note any custom changes you made to your Spine-Unity runtime.

  4. Delete your old "Spine" and "Spine Examples" folders.

  5. Close the project and Unity.

  6. Replace the old exported 3.7 skeleton assets with their re-exported 3.8 counterparts.

  7. Open Unity and your project again.

  8. Import the latest Spine-Unity 3.8 unitypackage.

Adapting your code to 3.8 API changes
For notable changes to the API, please see the Changelog, sections C# and Unity
spine-runtimes/CHANGELOG.md at 3.8

Some methods have been renamed or replaced in 3.8.
If you receive compile errors from your own code because of using renamed and no-longer existing methods, the following steps will help to quickly make your own code compatible again:

  1. Replace any usage of Skin.AddAttachment() with Skin.SetAttachment().

  2. Replace any usage of Skin.FindAttachmentsForSlot() and Skin.FindNamesForSlot() with the combined Skin.GetAttachments(int slotIndex, List<SkinEntry> attachments) method:

    // replace this code:
    List<Attachment> attachments = new List<Attachment>();
    List<string> names = new List<string>();
    skin.FindAttachmentsForSlot(slot, attachments);
    skin.FindNamesForSlot(slot, names);
    string name = names[index];
    string attachment = attachments[index];
    // with this code:
    List<Skin.SkinEntry> entries = new List<Skin.SkinEntry>();
    skin.GetAttachments(slot, entries);
    string name = entries[index].Name;
    string attachment = entries[index].Attachment;
    
  3. PoseSkeleton() and PoseWithAnimation() extension methods were removed. As a replacement you can use AnimationState.ClearTrack(0); followed by var entry = AnimationState.SetAnimation(0, animation, loop); entry.TrackTime = time to achieve similar behaviour.

  4. Replace usage of Attachment.GetClone() with Attachment.Copy() and usage of MeshAttachment.GetLinkedClone() with MeshAttachment.NewLinkedMesh().

  5. Replace usage of Attachment.GetClone(bool cloneMeshesAsLinked) with Attachment.GetCopy(bool cloneMeshesAsLinked)

  6. SkeletonDataAsset.atlasAssets is now an array of the base class AtlasAssetBase instead of SpineAtlasAsset, which provides an IEnumerable<> Materials instead of a List<> materials. So replace any access via atlasAsset.materials[0] with atlasAsset.Materials.First() and add a using System.Linq; statement at the top of your file.

  7. Replace using statements of using Spine.Unity.Modules.AttachmentTools; with using Spine.Unity.AttachmentTools;. You can remove using Spine.Unity.Modules; statements when a using Spine.Unity statement is already present in the file.

For a complete list of changes, see the spine-runtimes/CHANGELOG.md at 3.8.

Timeline Support has been moved to a separate UPM (Unity Package Manager) Package
See the changelog for more info:
spine-runtimes/CHANGELOG.md at 3.8

Changes of default values

  1. SkeletonMecanim's Layer Mix Mode now defaults to MixMode.MixNext instead of MixMode.MixAlways. Consider this when creating new SkeletonMecanim instances, existing ones are not affected. Note: for a short time, the default value was changed to MixMode.SpineStyle. MixMode.SpineStyle is now renamed to MixMode.Hard.

  2. BlendModeMaterialAsset and it's instance Default BlendModeMaterials.asset now have Apply Additive Material set to true by default in order to apply all blend modes by default.

You can download the new unitypackages from the download page: Spine Unity Download

If you find anything that should be noted or added to the guide, please do not hesitate to post it below so that we can make upgrading as easy and painless as possible for everyone.

We hope that you like the new Spine release and are able to create even more incredible games with it! 🙂

7 days later

Hey guys - I'm assuming I can follow this guide to upgrade from Spine-Unity 3.6 to 3.8, am I correct? Or do I need to upgrade to 3.7 first?

The basic steps of both upgrades can be combined to a single upgrade from 3.6 to 3.8.
Of course you have to adapt to code changes that happened from 3.6 to 3.7 as well, e.g. if you were using SkeletonAnimator in code, change it to SkeletonMecanim.

Just have a look at the changes that were introduced from 3.6 to 3.7 here:
Spine-Unity 3.6 to 3.7 Upgrade Guide

Thank you Harald!


After updating to 3.8, I got a lot of errors.

Updated your Spine-Unity runtime to 3.8 according to your guide.
Most of the problems have been solved successfully, but there is one problem.

Like the attached image, there are a lot of errors in "Assets \ Spine \ Runtime \ spine-unity \ Components \ SkeletonGraphic.cs" and I can't test the game.
Do you know this issue?
How can I solve this problem?

And I'm currently using Unity version 2019.3.0a5.
If the cause is in the Unity version, is there a version you recommend?

A couse of error is that class or namespace "MaskableGraphic" does't exist in Asset.

PandMEntertm wrote

And I'm currently using Unity version 2019.3.0a5.

Sorry to hear that you are facing problems. Thanks for providing the version info, that is exactly the reason why you receive these errors: Unity 2019.3 alpha is not supported by Spine yet. That is the reason why we state Compatible with Spine 3.8.x and Unity 2017.1-2019.2 on the download page and in the changelog.

We recommend using Unity 2019.2 in your case, but in general any Unity version listed as supported will be a good choice.

Dear Harald,
As you advised, I downgraded Unity.
A large amount of Prefab data has been corrupted, but the Spine animation can now be played back safely.
Thank you for your constant support.

I hope that all versions of Unity will be supported over time.

Also, I will take care not to inadvertently update Unity.

Prefab data has been corrupted by your Unity downgrade? That sounds terrible, sorry to hear that.

In general we will always strive to support the latest non-beta (and non-alpha) Unity versions when they are released. Unfortunately alpha versions will be too unstable for us (API wise it might change) to depend our code on too early.

Hello,
I'm unity3d c# programmer, but I have few spine animation, from different versions 3.7 and 3.8. How I can use it in one project without re-export. I dont have Spine, I ordered this animations. Thanks for a reply)

I'm afraid you must export from the version of Spine that matches the version of the runtime you are using. You could try using the JsonRollback tool to make 3.8 JSON compatible with 3.7 runtimes, but this is not officially supported:
Open project in an older version

Also please note that using the Spine Runtimes without a Spine license has restrictions: all users of your application will need their own Spine license. Read more here:
Spine Runtimes License Agreement

Thank you always, Harald.
My prefab was able to be restored with almost no damage the way I found it on the net.

But I still have problems.
I have a license for the latest version of Spine.
If you try to import a character created with it into Unity 2019.2.01f by drag and drop, Unity will crash.
However, deleting the imported file from Windows Explorer will no longer crash.

This problem happen only the case of Spine exported files, not other files(for example, png files).

Do you know how to solve this problem?
Did you also recognize this issue?
Please give me some advice.

P.S.
My problem is the same case of below URL:
Unity Crashes when importing spine files

Sorry to hear that. Unfortunately I could not reproduce this problem, using the latest unitypackage (spine-unity-3.8-2019-08-15.unitypackage) and data exported from Spine 3.8.60.
Which version of Spine did you use to export your files, was it also 3.8.60?

My problem is the same case of below URL:
Unity Crashes when importing spine files

Please note that the problem in the above thread was caused by mixing Spine versions: assets exported from Spine 3.7, imported in Spine-Unity 3.8 runtime.

Does this happen every time you are importing the asset via drag and drop? If yes, could you please send us your problematic exported assets as a zip file, to contact@esotericsoftware.com? Then we can have a look at it.

Dear Harald,

Thank you for your reply.

I tried as many times as I could until I received your reply, but I couldn't solve the problem.

Some data was lost, but I found an older version of Spine data in the backup data.

I will wait for the runtime to support Unity 2019.3x.

Hi,

I'm updating from Spine 3.6 to 3.8 and using Unity 2019.1.9f1.

I have a custom implementation of the mix and match script and I get the following error:

'AtlasAssetBase' does not contain a definition for 'materials' and no accessible extension method 'materials' accepting a first argument of type 'AtlasAssetBase' could be found (are you missing a using directive or an assembly reference?)

referring to the following code in Start():

skeletonAnimation = GetComponent<SkeletonAnimation>();
         if (sourceMaterial == null) 
         {
            if (skeletonAnimation != null)
               sourceMaterial = skeletonAnimation.SkeletonDataAsset.atlasAssets[0].Materials[0];
         }

What could be the issue?

Sorry for the trouble.

For some reason the error message does not completely fit the code (uppercase M vs lowercase m), however I assume that the problem is as follows:
The SkeletonDataAsset.atlasAssets array now holds an array of the base class AtlasAssetBase instead of SpineAtlasAsset, which provides an IEnumerable<> Materials instead of a List<> materials. Therefore the error should be resolved by replacing the access materials[0] with Materials.First() as follows:

// Add this using statement at the top of your file:
using System.Linq;
...
// replace this line:
// sourceMaterial = skeletonAnimation.SkeletonDataAsset.atlasAssets[0].Materials[0];
// with this line:
sourceMaterial = skeletonAnimation.SkeletonDataAsset.atlasAssets[0].Materials.First();

Thanks for reporting this problem, I have added an entry to the changelog and the list at the top.

Hi Harald,

No worries. Thanks!

5 days later

Hi Harald,

Im having an issue for some days i cannot resolve.
I updated to spine 3.8, using Unity 2019.2. Re exported all spines.

and i keep getting this error:
InvalidCastException: Specified cast is not valid.
Spine.Unity.Editor.SpineEditorUtilities.IssueWarningsForUnrecommendedTextureSettings (System.String texturePath) (at Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs:172)

And cannot edit the spine object (the skeleton animation component is broken).

Am i missing something here?

thanks a lot

We are sorry that you are having trouble!

Which version of the Spine-Unity runtime (name of the unitypackage as downloaded from here) are you using, and which version of the Spine Editor?
If using git, please note that the 3.8-beta branch has been replaced by the non-beta 3.8 branch in the meantime.

If both are latest available version (runtime spine-unity-3.8-2019-08-28.unitypackage and Spine 3.8.68), please send us a minimal Unity project that still shows the problem as a zip file. You can send it to contact@esotericsoftware.com.

Hi Herald!

Thanks for responding.

I exported the file using Spine 3.8.68, and using the unity package "spine-unity-3.8-2019-08-23".
I will send you a zip file.

Thanks again