• Unity
  • Importing additional animations to character error

Related Discussions
...

I'm getting an error in Unity when I re-export my Spine JSON into Unity. I've aded a new animation but I'm now getting this error and the new animation doesn't show up in my character Animation Controller in Unity. IS DOES however show up in my SkeletonData which is strange since I've re-exported this Spine file a number of times with no problems before, this is the first time I'm getting this error. My Animation Controller always auto-updated to match the animations in SkeletonData How do I get my Animation Controller to update to reflect the new animations added to SkeletonData? Is there a way to rebuild the dictionary or another way to fix this?

ArgumentException: An element with the same key already exists in the dictionary.
System.Collections.Generic.Dictionary`2[System.String,UnityEngine.AnimationClip].Add (System.String key, UnityEngine.AnimationClip value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404)
SkeletonBaker.GenerateMecanimAnimationClips (.SkeletonDataAsset skeletonDataAsset) (at Assets/spine-unity/Assets/spine-unity/Editor/SkeletonBaker.cs:405)
SpineEditorUtilities.UpdateMecanimClips (.SkeletonDataAsset skeletonDataAsset) (at Assets/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs:476)
SpineEditorUtilities.ResetExistingSkeletonData (System.String skeletonJSONPath) (at Assets/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs:461)
SpineEditorUtilities.ImportSpineContent (System.String[] imported, Boolean reimport) (at Assets/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs:334)
SpineEditorUtilities.OnPostprocessAllAssets (System.String[] imported, System.String[] deleted, System.String[] moved, System.String[] movedFromAssetPaths) (at Assets/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs:283)
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-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
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-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:27)

Are you on the latest runtime?

I have to fix this every now and then.. not sure if it's the perfect change but here's what I do to SkeletonBaker.cs line 405 area

		foreach (var o in objs) {
			if (o is AnimationClip) {
                if(!clipTable.ContainsKey(o.name))
				    clipTable.Add(o.name, (AnimationClip)o);
			}
		}
16 days later

Thanks, Majicpanda. I'll add this to the issues list.

2 months later

I just downloaded the latest Spine - Unity assets, and this bug was still happening.
Just reporting.

Fixed as described here.

The unitypackage hasn't been updated yet. That's scheduled for today.

Pharan wrote

The unitypackage hasn't been updated yet. That's scheduled for today.

Great news Pharan, that means the Spine V3 will be available with SkeletonUitility (believe that was the issue) ?

No, it's just the regular update of the unitypackage with the latest changes from github.