The SetPosition extension method is shorthand for setting bone.X and bone.Y on the spine-csharp side. These are the local x and y positions of that bone.
The normal execution order for SkeletonAnimation goes like this:
0.
Unity's script execution order may run scripts here
SkeletonAnimation.Update()
skeleton.Update() <
this does nothing right now.
state.Update() <
advances the Spine.AnimationState by Time.deltaTime.
state.Apply(skeleton) <
applies the animations in Spine.AnimationState to the skeleton. This also includes firing events.
skeleton.UpdateWorldTransform() <
traverses the skeleton bone hierarchy and calculates all bone world positions. This also includes applying constraints.
5.
Unity's script execution order may run scripts here
SkeletonAnimation.LateUpdate() <
Generates the mesh. Iterates through all the attachments and makes a mesh based on them. This uses the bone world positions.
tl;dr
Depending on both when your code runs and if animations are also keying the position of the bone, it may not take effect.
SkeletonAnimation has some useful callbacks for this purpose. You may want to do it like in this sample code:
using UnityEngine;
using Spine;
using Spine.Unity;
public class RootBoneMover : MonoBehaviour {
public Bone rootBone;
public Vector2 rootBonePosition;
void Start () {
var skeletonAnimation = GetComponent<SkeletonAnimation>();
skeletonAnimation.UpdateLocal += HandleUpdateLocal;
rootBone = skeletonAnimation.skeleton.RootBone;
}
void HandleUpdateLocal (ISkeletonAnimation s) {
rootBone.SetPosition(rootBonePosition); // rootBone.X = rootBonePosition.x; rootBone.Y = rootBonePosition.y;
}
}