- Edited
Error importing data into Unity with spine 4
Hello,
I'm looking into upgrading our Unity runtime from 3.8 to 4.0-2021-08-16, and I'm having trouble importing the re-exported characters that I exported with Spine Pro 4.0.23. Some of our spine characters import fine, but the more complex ones don't load in unity and give the error:
Error reading skeleton JSON file for SkeletonData asset: cha_littlePeople_SkeletonData
Error reading animation: torch_animations/anm_walk_torch
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at Spine.SkeletonJson.ReadSkeletonData (System.IO.TextReader reader) [0x01393] in C:\isaac\mm-bitbucket\ce2-console\Assets\Plugins\Spine\Runtime\spine-csharp\SkeletonJson.cs:368
at Spine.Unity.SkeletonDataAsset.ReadSkeletonData (System.String text, Spine.AttachmentLoader attachmentLoader, System.Single scale) [0x00017] in C:\isaac\mm-bitbucket\ce2-console\Assets\Plugins\Spine\Runtime\spine-unity\Asset Types\SkeletonDataAsset.cs:258
at Spine.Unity.SkeletonDataAsset.GetSkeletonData (System.Boolean quiet) [0x000c4] in C:\isaac\mm-bitbucket\ce2-console\Assets\Plugins\Spine\Runtime\spine-unity\Asset Types\SkeletonDataAsset.cs:173
UnityEngine.Debug:LogError (object,UnityEngine.Object)
Spine.Unity.SkeletonDataAsset:GetSkeletonData (bool) (at Assets/Plugins/Spine/Runtime/spine-unity/Asset Types/SkeletonDataAsset.cs:176)
I've emailed one of the exported characters to contact@esotericsoftware.com - please can you look and let me know if this is a bug or an issue with our export settings? I've tried the usual tricks of deleting and re-exporting/importing of course, including with a brand new unity project and a fresh spine import. I'm using Unity 2020.3.14f1.
Thanks,
Isaac
We are very sorry for the troubles! It seems to be an issue with export from Spine, as it does not only occur with the spine-unity runtime.
It's now tracked under this issue ticket:
https://github.com/EsotericSoftware/spine-runtimes/issues/1930
If you would like to use a different solution in the meantime, you can export the same skeleton from Spine in binary format as .skel.bytes
instead of as .json
. This should export your data without triggering the bug. You can rename your skeleton.json.meta
file to skeleton.skel.bytes.meta
in the Unity project as well in order not to loose any references (but anyway, the SkeletonDataAsset should find the binary .skel.bytes
file).