• Runtimes
  • Spine Runtime causing a fatal error in Unity Editor

Related Discussions
...

I'm not quite sure what this is about, but this is the error I'm seeing. This causes some minor issues with my code (my character cannot run left or right but all of the other controls work fine) but the real issue is that if I've run the editor at all, it erases my hierarchy view and I can't select anything until I restart the whole editor.

I don't think this has anything to do with my code. I updated Unity to the latest version and then downloaded the latest Spine Runtimes yesterday. Can someone assist?

ArgumentException: An element with the same key already exists in the dictionary.
System.Collections.Generic.Dictionary`2[System.Int32,UnityEngine.GameObject].Add (Int32 key, UnityEngine.GameObject value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404)
Spine.Unity.Editor.SpineEditorUtilities.HierarchyIconsOnChanged () (at Assets/spine-unity/Editor/SpineEditorUtilities.cs:538)
Spine.Unity.Editor.SpineEditorUtilities.HierarchyIconsOnPlaymodeStateChanged (PlayModeStateChange stateChange) (at Assets/spine-unity/Editor/SpineEditorUtilities.cs:527)
Spine.Unity.Editor.SpineEditorUtilities.Initialize () (at Assets/spine-unity/Editor/SpineEditorUtilities.cs:238)
Spine.Unity.Editor.SpineEditorUtilities..cctor () (at Assets/spine-unity/Editor/SpineEditorUtilities.cs:200)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Spine.Unity.Editor.SpineEditorUtilities
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (RuntimeTypeHandle type) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Runtime.CompilerServices/RuntimeHelpers.cs:101)
UnityEditor.EditorAssemblies.ProcessEditorInitializeOnLoad (System.Type type) (at C:/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:136)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:295)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:288)
UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:255)
UnityEngine.GUIUtility😛rocessEvent(Int32, IntPtr)

Thanks for reporting and posting the full stacktrace!
That looks really serious. I'm not sure what's causing it the chain of events. Maybe you have multiple hierarchy windows open or something. But I can make the code safer so this doesn't happen.

I've applied the change in git.
You can apply it to your project immediately by replacing your SpineEditorUtilities.cs file with this: https://raw.githubusercontent.com/EsotericSoftware/spine-runtimes/3.6/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs

This change will be included in the next unitypackage update.

You're quite welcome; fix works like a charm. :yes:

Great! Thanks for letting us know.