Hey, we're having a new issue with the Spine Runtimes failing to instantiate one of our skeletons.

Unity Version: v6000.0.11f1
Spine Runtime Version: v4.2.29 (GitHub Revision #b17595d)

The most curious part is that it properly imports, loads, and instantiated the first time. But if the code recompiles, the SkeletonAnimation immediately stops rendering and I'm unable to get it to render again properly.

None of the following work to fix the issue (nor combinations of these):
Removing and reimporting the json and atlas files
Reloading the Scene
Removing the SkeletonAnimation and trying to instantiate a new one
Restarting Unity

I was able to get it to work again, once, by removing the .spine and atlas files, removing the SkeletonAnimation, unloading the scene, restarting Unity, importing the json and atlas files, loaded the scene, and instantiated a new SkeletonAnimation with that json file. The moment Unity compiled though, it broke the SkeletonData again.

I also just noticed that somehow about a hundred of these SkeletonAnimation were added to my main control scene (we additively load our scenes, but I've never added this skeleton to our control scene).

Upon Removing and reimporting the json and atlas files we get the following error message in the console:

NullReferenceException: Object reference not set to an instance of an object
Spine.Unity.Editor.BlendModeMaterialsUtility.CreateOrLoadReplacementMaterial (Spine.AtlasRegion originalRegion, UnityEngine.Material materialTemplate, System.String materialSuffix, System.Boolean& createdNewMaterial) (at Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs:210)
Spine.Unity.Editor.BlendModeMaterialsUtility.CreateForRegion (System.Collections.Generic.List`1[Spine.Unity.BlendModeMaterials+ReplacementMaterial]& replacementMaterials, System.Boolean& anyReplacementMaterialsChanged, Spine.AtlasRegion originalRegion, UnityEngine.Material materialTemplate, System.String materialSuffix, Spine.Unity.SkeletonDataAsset skeletonDataAsset) (at Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs:172)
Spine.Unity.BlendModeMaterials.CreateAndAssignMaterials (Spine.Unity.SkeletonDataAsset skeletonDataAsset, Spine.Unity.BlendModeMaterials+TemplateMaterials templateMaterials, System.Boolean& anyReplacementMaterialsChanged, System.Action`1[T] clearSkeletonDataAssetFunc, System.Action`1[T] afterAssetModifiedFunc, Spine.Unity.BlendModeMaterials+CreateForRegionDelegate createForRegionFunc) (at Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs:173)
Spine.Unity.Editor.BlendModeMaterialsUtility.CreateAndAssignMaterials (Spine.Unity.SkeletonDataAsset skeletonDataAsset, Spine.Unity.BlendModeMaterials+TemplateMaterials templateMaterials, System.Boolean& anyReplacementMaterialsChanged) (at Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs:155)
Spine.Unity.Editor.BlendModeMaterialsUtility.UpdateBlendModeMaterials (Spine.Unity.SkeletonDataAsset skeletonDataAsset, Spine.SkeletonData& skeletonData, System.Boolean upgradeFromModifierAssets) (at Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs:86)
Spine.Unity.Editor.AssetUtility.IngestSpineProject (UnityEngine.TextAsset spineJson, Spine.Unity.AtlasAssetBase[] atlasAssets) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:1062)
Spine.Unity.Editor.AssetUtility.ImportSpineContent (System.String[] imported, System.Collections.Generic.List`1[T] texturesWithoutMetaFile, System.Boolean reimport) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:462)
Spine.Unity.Editor.AssetUtility.HandleOnPostprocessAllAssets (System.String[] imported, System.Collections.Generic.List`1[T] texturesWithoutMetaFile) (at Assets/Spine/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 Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs:102)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ce95f63947c64e4bbf5929ebe610c440>: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 <ce95f63947c64e4bbf5929ebe610c440>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <ce95f63947c64e4bbf5929ebe610c440>:0)
UnityEditor.AssetPostprocessingInternal.InvokeMethod (System.Reflection.MethodInfo method, System.Object[] args) (at /Users/bokken/build/output/unity/unity/Editor/Mono/AssetPostprocessor.cs:1168)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets, System.Boolean didDomainReload) (at /Users/bokken/build/output/unity/unity/Editor/Mono/AssetPostprocessor.cs:403)
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[], Boolean)
UnityEditorInternal.InternalEditorUtility:ProjectWindowDrag(HierarchyProperty, Boolean)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:219)

Upon trying to drag and drop the SkeletonData into a Scene as a SkeletonAnimation the console displays the following error:

NullReferenceException: Object reference not set to an instance of an object
Spine.Unity.Editor.EditorInstantiation.InstantiateSkeletonAnimation (Spine.Unity.SkeletonDataAsset skeletonDataAsset, Spine.Skin skin, System.Boolean destroyInvalid, System.Boolean useObjectFactory) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:1368)
Spine.Unity.Editor.SpineEditorUtilities+DragAndDropInstantiation+<>c.<ShowInstantiateContextMenu>b__2_0 (Spine.Unity.SkeletonDataAsset data) (at Assets/Spine/Editor/spine-unity/Editor/Utility/Instantiation.cs:105)
Spine.Unity.Editor.SpineEditorUtilities+DragAndDropInstantiation.HandleSkeletonComponentDrop (System.Object spawnMenuData) (at Assets/Spine/Editor/spine-unity/Editor/Utility/Instantiation.cs:150)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at /Users/bokken/build/output/unity/unity/Editor/Mono/GUI/GenericMenu.cs:125)

I've sent the offending spine project to your email address in-case it's something wrong with our Spine file (and to potentially help you pinpoint the issue if something is wrong with the runtimes).

Thank you for your time and any help you might be able to provide!

    Related Discussions
    ...

    ExNull-Tyelor Unfortunately, the spine-unity runtime does not yet support Unity 6. The latest Unity version supported by the spine-unity runtime is Unity 2023.1. Please use a supported version.

      Misaki No other skeleton in our game has this issue, and we've had no other issues with our Spine Runtimes since updating from Unity 2021.3.20f1 to the Unity 6000.0.11f1

      Re-exporting the file seemingly solved the issue though, so hopefully it resolved itself on its own?

        ExNull-Tyelor It is often the case that it may appear to work even if you are using an unsupported version, but there may be traps such as not working properly after building, so we do not recommend using an unsupported version.

        I imported the skeleton data files you sent us into a Unity 2022 project and tried to instantiate it, but I was unable to reproduce the same problem. If you are able to reproduce the same problem with the version supported by spine-unity 4.2, we would be grateful if you could let us know.

        @ExNull-Tyelor Thanks for reporting and for sharing the stack trace! Unfortunately I could not reproduce the issue on my end with Unity 6000.0.16.

        In general we are happy to receive bugreports for unsupported Unity versions to be able to support it officially in the near future.

        ExNull-Tyelor Spine Runtime Version: v4.2.29 (GitHub Revision #b17595d)

        Note that you are using a pretty old version of the spine-unity 4.2 runtime, the current version being 4.2.86, so there have been 31 patch releases since then, potentially already fixing the cause of this issue.

        We've just pushed a commit which should prevent the above exception.
        A new spine-unity 4.2 unitypackage is available for download:
        https://esotericsoftware.com/spine-unity-download
        If you encounter a similar issue in the future, please let us know and send us a minimal version of your problematic Unity project via email together with reproduction steps.

        Thanks for both of your replies!

        It is seemingly working for me now as well, so I'm just going to assume it was Unity bugging out on me unless I'm able to reliably reproduce the issue once again to confirm otherwise.

        I'll probably also follow your suggestion and update the Spine Runtimes early next week as well, and probably update my Unity Editor too since they just released a bug fix in 6000.0.20 for a bug I reported.