• EditorBugs
  • [Unity 6] Downgrade and upgrade version Unity cause Spine InvalidCastException

I'm currently using Unity 6 vers 6000.0.31f1 with Spine 4.2. I have to downgrade the project to 2022.3.48f1. The scripts error due to no linearVelocity detected. I fix it by re-import Spine 4.2. At this time, everything is normal. For some reason, I have to migrate again to Unity 6 vers 6000.0.32f1 and whenever I start the game, even after i re-import Spine, it keeps throw
Err 1:
InvalidCastException: Specified cast is not valid.
Spine.Unity.Editor.SkeletonGraphicInspector.DisableEditReferenceRectMode () (at Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs:233)
Spine.Unity.Editor.SkeletonGraphicInspector.OnDisable () (at Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs:220)

Err 2:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.GameObjectInspector.OnDisable () (at <878b6c863a9e4c42bf8483a7b6c60e0b>:0)

Err3:
SerializedObjectNotCreatableException: Object at index 0 is null
UnityEditor.Editor.CreateSerializedObject () (at <878b6c863a9e4c42bf8483a7b6c60e0b>:0)
UnityEditor.Editor.GetSerializedObjectInternal () (at <878b6c863a9e4c42bf8483a7b6c60e0b>:0)
UnityEditor.Editor.get_serializedObject () (at <878b6c863a9e4c42bf8483a7b6c60e0b>:0)
UnityEditor.RectTransformEditor.OnEnable () (at <878b6c863a9e4c42bf8483a7b6c60e0b>:0)

Err4:
SerializedObjectNotCreatableException: Object at index 0 is null
UnityEditor.Editor.CreateSerializedObject () (at <878b6c863a9e4c42bf8483a7b6c60e0b>:0)
UnityEditor.Editor.GetSerializedObjectInternal () (at <878b6c863a9e4c42bf8483a7b6c60e0b>:0)
UnityEditor.Editor.get_serializedObject () (at <878b6c863a9e4c42bf8483a7b6c60e0b>:0)
Spine.Unity.Editor.SkeletonGraphicInspector.OnEnable () (at Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs:153)

Err5:
MissingReferenceException: The variable m_Targets of GameObjectInspector doesn't exist anymore.
You probably need to reassign the m_Targets variable of the 'GameObjectInspector' script in the inspector. Parameter name: componentOrGameObject
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at <44f3679c53d1477a9c6e72f269e3a3a9>:0)
UnityEngine.Bindings.ThrowHelper.ThrowArgumentNullException (System.Object obj, System.String parameterName) (at <44f3679c53d1477a9c6e72f269e3a3a9>:0)
UnityEditor.PrefabUtility.IsPartOfVariantPrefab (UnityEngine.Object componentOrGameObject) (at <878b6c863a9e4c42bf8483a7b6c60e0b>:0)
UnityEditor.GameObjectInspector.OnEnable () (at <878b6c863a9e4c42bf8483a7b6c60e0b>:0)

The spine version which I used to create is 4.2.37. Please check this out.

Related Discussions
...

@ninetailgt That's strange indeed, thanks for reporting. While we could not reproduce the issue, we've now fixed multiple occurrances in SkeletonGraphicInspector which might potentially throw an InvalidCastException. Please do let us know if this resolves the issues on your end.

A new spine-unity 4.2 unitypackage has been released:
https://esotericsoftware.com/spine-unity-download

Issue ticket URL for later reference:
EsotericSoftware/spine-runtimes2718

5 jours plus tard

@Harald Apologies for the late response, but I have some great news, sfter a few restarts and a reinstallation, the old Spine version is now running smoothly.
The issue turned out to be minor, but it was causing some frustration whenever I tried to debug. Thankfully, everything seems to be working perfectly now.
Thank you so much for your support and guidance! It really helped me work through the problem.

8 jours plus tard

Googling this error brought me to this page. At least the last few errors seem to be an issue with Unity 6. I do not have any spine runtimes installed.
Restarting the editor fixes these errors for a time