Hey guys, having spent couple of days on this topic however and am still kind of messed.
I know there is a Bone.WorldX
represents the "relative position" of the specific bone based on center node of root, however when trying to access the property for a SkeletonGraphic(UI) component within a Canvas it gets wired:
Slot headSlot = skeleton.Skeleton.FindSlot("head");
Bone headBone = headSlot.Bone;
Debug.Log(skeleton.rectTransform.rect.size.x); // Rendered size at 200px;
Debug.Log((headSlot.Attachment as MeshAttachment).Region.OriginalHeight); // the original head in PNG is around 300+px;
Debug.Log(skeleton.SkeletonData.Width); // the full size of skeleton be at 2000+px;
Debug.Log(headBone.WorldX); // !!! -> get results like 0.01xxx
Debug.Log(headBone.WorldY); // !!! -> get results like 1.12yyy
That everything looked fine, just the worldX and worldY become extrimly small and doesn't seem to represent anything useful.
For more context, I have skeleton.SkeletonDataAsset.scale == 0.001
as the original texture being very big, while worldY / skeleton.SkeletonDataAsset.scale
in this case would go beyond the rendered/original Height of the skeleton.
Reason I need the position is I need to find the relative position for the target bone from its parent in percentage, thus I need to figure the relative position first, and then some a W/H for the skeleton under the same context with the position. So any other alternatives other than worldX/Y would be more ideal.
Any ideas? Thanks!