mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
[unity] Bone.SetPositionSkeletonSpace
This commit is contained in:
parent
a96d92d27d
commit
3a1b77871f
@ -185,6 +185,20 @@ namespace Spine.Unity {
|
||||
bone.WorldToLocal(worldPosition.x, worldPosition.y, out o.x, out o.y);
|
||||
return o;
|
||||
}
|
||||
|
||||
/// <summary>Sets the skeleton-space position of a bone.</summary>
|
||||
/// <returns>The local position in its parent bone space, or in skeleton space if it is the root bone.</returns>
|
||||
public static Vector2 SetPositionSkeletonSpace (this Bone bone, Vector2 skeletonSpacePosition) {
|
||||
if (bone.parent == null) { // root bone
|
||||
bone.SetPosition(skeletonSpacePosition);
|
||||
return skeletonSpacePosition;
|
||||
} else {
|
||||
var parent = bone.parent;
|
||||
Vector2 parentLocal = parent.WorldToLocal(skeletonSpacePosition);
|
||||
bone.SetPosition(parentLocal);
|
||||
return parentLocal;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Attachments
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user