my spine version is 3.8 and i have a question.
I use spine for Unity.
characters are using SpineAnimation Component for moving and change skin.
but for some complex reason, thier skins are in different SkeletonDataAsset
and i have to change it on runtime.
So I did as below.
SkeletonDataAsset skeletonDataAsset = ResourceManager.ResourcesObjectLoad<SkeletonDataAsset>(_SkeletonDataAssetPath);
if (skeletonDataAsset == null)
return false;
_Skeleton.skeletonDataAsset = skeletonDataAsset;
_SkeletonAnimation.initialSkinName = skinName;
_SkeletonAnimation.Initialize(true);
Despite the change of skeleton asset data, character have to maintain state. So, i copied prev
AnimationState, to assign it in initialized SkeletonAnimation.
AnimationState state = _SkeletonAnimation.AnimationState;
SkeletonDataAsset skeletonDataAsset = ResourceManager.ResourcesObjectLoad<SkeletonDataAsset>(_SkeletonDataAssetPath);
if (skeletonDataAsset == null)
return false;
_Skeleton.skeletonDataAsset = skeletonDataAsset;
_SkeletonAnimation.initialSkinName = skinName;
_SkeletonAnimation.Initialize(true);
_SkeletonAnimation.state = state;
and this error code printed.
IndexOutOfRangeException: Index was outside the bounds of the array.
Spine.RotateTimeline.Apply (Spine.Skeleton skeleton, System.Single lastTime, System.Single time, Spine.ExposedList1[T] firedEvents, System.Single alpha, Spine.MixBlend blend, Spine.MixDirection direction)
(at Assets/Spine/Runtime/spine-csharp/Animation.cs:351)
Spine.AnimationState.ApplyRotateTimeline (Spine.RotateTimeline timeline, Spine.Skeleton skeleton, System.Single time, System.Single alpha, Spine.MixBlend blend, System.Single[] timelinesRotation, System.Int32 i, System.Boolean firstFrame)
(at Assets/Spine/Runtime/spine-csharp/AnimationState.cs:505)
Spine.AnimationState.ApplyMixingFrom (Spine.TrackEntry to, Spine.Skeleton skeleton, Spine.MixBlend blend)
(at Assets/Spine/Runtime/spine-csharp/AnimationState.cs:406)
Spine.AnimationState.Apply (Spine.Skeleton skeleton)
(at Assets/Spine/Runtime/spine-csharp/AnimationState.cs:242)
Spine.Unity.SkeletonAnimation.ApplyAnimation ()
(at Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs:217)
Spine.Unity.SkeletonAnimation.Update (System.Single deltaTime)
(at Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs:203)
Spine.Unity.SkeletonAnimation.Update () (at Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs:188)
I thought the reason is gap between prev and curr skin bone count, so added this code.
if (skeleton.bones.Items.Length <= boneIndex)
boneIndex = 0;
Bone bone = skeleton.bones.Items[boneIndex];
Could this cause problems? I'm in dire need of help. Thank you.