i am trying to use the skeleton render separator as I have always done so far but this time I get an error in Unity making it impossible to separate my slots :'(

I am using spine 4.0.33
Unity is 2020.3.12
the spine runtime is the latest (compatible with 4.0.xx)

so, whenever I try to add a separator slot (either in the advanced section of skeletonAnimation or in the skeleton render separator component) I get this error in the console
NullReferenceException: Object reference not set to an instance of an object
Spine.Unity.Editor.SkeletonRendererInspector.SeparatorsField (UnityEditor.SerializedProperty separatorSlotNames) (at Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs:486)
Spine.Unity.Examples.SkeletonRenderSeparatorInspector.OnInspectorGUI () (at Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonRenderSeparatorInspector.cs:150)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Editor/Inspector/InspectorElement.cs:546)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
Is there anything I can do to fix?
  • 記事: 40


from the code:
int index = skeleton.Data.FindSlot(slotName).Index;
Harald, I believe there might be an issue with this change: https://github.com/EsotericSoftware/spine-runtimes/commit/8770e319c5735745e506aad413dc231e0bbc99c3
in a few places.
By default [SpineSlot]/Unity sets the value to empty string ("") which will not find the slot and return null when adding new elements to the lists and could cause a few exceptions like the above.

I tried this on my side and it seems to solve the exception:
string slotName = separatorSlotNames.GetArrayElementAtIndex(i).stringValue;
SlotData slot = skeleton.Data.FindSlot(slotName);
int index = -1;
if (slot != null) {
index = slot.Index;
which is basically almost like what the FindSlotIndex was previously doing (I mean the return of -1).
  • 記事: 36


Oh dear, very sorry for the troubles and thanks very much for reporting! I missed that some methods were built to accept the -1 slot index as input parameter and continued safely.

A bugfix has been pushed, a new 4.0 spine-unity unitypackage is available for download:
Spine Unity Download

  • 記事: 3353

Return to Unity