• EditorBugs
  • 我在使用spine4.2.20制作动画,导入到unity时发生了报错,我的unity版本为2022.3.0

我在使用spine4.2.20制作动画,导入到unity时发生了报错,我的unity版本为2022.3.0,报错日志如下
IndexOutOfRangeException: Index was outside the bounds of the array.
Spine.CurveTimeline..ctor (System.Int32 frameCount, System.Int32 bezierCount, System.String[] propertyIds) (at ./Library/PackageCache/com.esotericsoftware.spine.spine-csharp@86a320afc2/Animation.cs:297)
Spine.IkConstraintTimeline..ctor (System.Int32 frameCount, System.Int32 bezierCount, System.Int32 ikConstraintIndex) (at ./Library/PackageCache/com.esotericsoftware.spine.spine-csharp@86a320afc2/Animation.cs:2026)
Spine.SkeletonBinary.ReadAnimation (System.String name, Spine.SkeletonBinary+SkeletonInput input, Spine.SkeletonData skeletonData) (at ./Library/PackageCache/com.esotericsoftware.spine.spine-csharp@86a320afc2/SkeletonBinary.cs:886)
Spine.SkeletonBinary.ReadSkeletonData (System.IO.Stream file) (at ./Library/PackageCache/com.esotericsoftware.spine.spine-csharp@86a320afc2/SkeletonBinary.cs:390)
Spine.Unity.Editor.AssetUtility.AddRequiredAtlasRegionsFromBinary (System.String skeletonDataPath, System.Collections.Generic.List
1[T] requiredPaths) (at ./Library/PackageCache/com.esotericsoftware.spine.spine-unity@86a320afc2/Editor/spine-unity/Editor/Utility/AssetUtility.cs:223)
Spine.Unity.Editor.AssetUtility.GetRequiredAtlasRegions (System.String skeletonDataPath) (at ./Library/PackageCache/com.esotericsoftware.spine.spine-unity@86a320afc2/Editor/spine-unity/Editor/Utility/AssetUtility.cs:140)
Spine.Unity.Editor.AssetUtility.ImportSpineContent (System.String[] imported, System.Collections.Generic.List1[T] texturesWithoutMetaFile, System.Boolean reimport) (at ./Library/PackageCache/com.esotericsoftware.spine.spine-unity@86a320afc2/Editor/spine-unity/Editor/Utility/AssetUtility.cs:437)
Spine.Unity.Editor.AssetUtility.HandleOnPostprocessAllAssets (System.String[] imported, System.Collections.Generic.List
1[T] texturesWithoutMetaFile) (at ./Library/PackageCache/com.esotericsoftware.spine.spine-unity@86a320afc2/Editor/spine-unity/Editor/Utility/AssetUtility.cs:117)
Spine.Unity.Editor.SpineEditorUtilities.OnPostprocessAllAssets (System.String[] imported, System.String[] deleted, System.String[] moved, System.String[] movedFromAssetPaths) (at ./Library/PackageCache/com.esotericsoftware.spine.spine-unity@86a320afc2/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs:98)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <6aa56e57ab504395b555cf3ed50fa53d>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <6aa56e57ab504395b555cf3ed50fa53d>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <6aa56e57ab504395b555cf3ed50fa53d>:0)
UnityEditor.AssetPostprocessingInternal.InvokeMethod (System.Reflection.MethodInfo method, System.Object[] args) (at <505360e321ae48e3804e227a34262e1e>:0)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets, System.Boolean didDomainReload) (at <505360e321ae48e3804e227a34262e1e>:0)
UnityEditor.AssetPostprocessingInternal😛ostprocessAllAssets(String[], String[], String[], String[], String[], Boolean)
`
我不知道发生了什么,我只能提供我导出的设置如下:

当我将导出的文件放入unity工程中时,发生了报错。
我觉得值得一提的是,我之前4.2.20做出来的动画并没有发生过这种事情,同样的导出设置,同样的流程,这是第一次出错。

Related Discussions
...

根据你提供的错误日志和导出设置,问题可能出在导出的Spine动画文件中某些数据格式或命名不一致。以下是一些可能的解决方案:

  1. 检查附件命名:确保你的附件名称中没有包含特殊字符或文件扩展名(如.png),这可能会导致导入时无法正确匹配附件。参考之前的一个类似问题,附件名称中包含.png会导致导入错误。

  2. 重新打包纹理:如果你在导出时修改了任何纹理或附件名称,确保重新打包纹理并导出新的Spine动画文件。

  3. 更新Spine和Unity插件:确保你使用的是最新版本的Spine和spine-unity插件。某些版本之间可能存在兼容性问题。

  4. 检查导出设置:确保你的导出设置与Unity项目设置匹配。特别是检查Spine导出设置中的纹理打包选项和Unity项目中的纹理设置。

  5. 导入步骤:按照以下步骤重新导入Spine动画文件:

    • 删除Unity项目中现有的Spine动画文件。
    • 确保所有相关的Atlas和JSON文件都在同一目录下。
    • 重新导入这些文件到Unity项目中。

如果以上方法仍然无法解决问题,建议你可以尝试以下步骤来进一步排查问题:

  1. 导出日志:在Spine中导出时,查看导出日志是否有任何警告或错误信息。
  2. 简化项目:尝试导出一个简单的Spine项目并导入到Unity中,看看是否能重现问题。这可以帮助确定问题是否与特定的动画或设置有关。

希望这些建议能帮助你解决问题。如果问题依然存在,请提供更多的错误日志和导出设置截图,以便进一步分析。

@tianlluo This looks like the spine-unity runtime is outdated. Which exact version of the spine-unity runtime (name of the unitypackage, also listed in Assets/Spine/version.txt, or in the Unity Package Manager if installed this way) are you using? If it's not the latest version from the download page, please update the spine-unity package.

    Harald

    我用的应该是最新的runtime了

    @tianlluo Thanks for the info. Could you please also have a try updating the Spine Editor version to the latest version?

    How did you export the atlas assets? Are both the .atlas.txt file and the png atlas textures all exported along with the skeleton export? Did you receive any warnings during export?

      Harald

      我解决了这个问题,我将unity package manager里的相关的runtime package删除了,然后在官网下了 untiypackage文件,将runtime装到了工程 asset目录下,问题就解决了,我感觉可能是使用unity package manager升级导致的bug。

      I solved this problem by deleting the relevant runtime package in the Unity package Manager, then downloading the UnityPackage file from the official website and installing the runtime into the project's asset directory. The problem was resolved. I suspect that the upgrade using the Unity Package Manager may have caused the bug.

        tianlluo Glad to hear it has been resolved! By the way, you don't need to include an English translation in your reply, as we can read your reply using the Translate button. Thank you for getting back to us!

        @tianlluo Glad to hear the issue has been resolved, thanks for getting back to us!

        If you would prefer to use the Unity Package Manager instead of the unitypackage, perhaps the URL of the package was wrong and still containing #4.2-beta at the end instead of 4.2? It should be e.g. https://github.com/EsotericSoftware/spine-runtimes.git?path=spine-unity/Assets/Spine#4.2