YasinB Hello, I have a problem with fitting SkeletonGraphic in Unity. In my Spine project, seperate skins come together to form a complete skin. For example, different skins can be selected for the character's shoes, upper body and lower body to create variations. I don't have a problem when using these skins together (Only when whote body is shown). However, when I use the "MatchRectTransformWithBounds" method when showing the skin separately, the reference rectangle does not exactly match the dimensions of the skin. A rectangle is created that always includes the root pivot point. This makes it impossible to show the skin separately. I am sharing a few pictures below. Thanks. Canvas Settings Full Body Example Only Shirt Example Only Ear Example
YasinB I calculated the bounds using the created meshes with or without the "MatchRectTransformWithBounds" method. However, the root position was also included in the bounds I calculated from the mesh. Note that the entire skeleton is created at runtime.
Harald @YasinB Sorry for the troubles and thanks for reporting! This is is due to a bug in Unity's Mesh bounds computation including unused (non-indexed) padding vertices in the computation. We've just pushed a workaround for this issue. See this issue ticket here for details: EsotericSoftware/spine-runtimes2701 A new spine-unity 4.2 unitypackage is available for download here as usual: https://esotericsoftware.com/spine-unity-download Please let us know if this resolves the issues on your end as well.
YasinB The size problem is gone but the problem with the pivot point is still there. The alignment is not correct. Am I missing something? I am sharing the image below.
Harald YasinB The size problem is gone but the problem with the pivot point is still there. The alignment is not correct. Am I missing something? I am sharing the image below. The pivot is the skeleton's origin, this is independent of the mesh bounds. If you want the pivot elsewhere, you can move the blue pivot to e.g. the center of the mesh bounds (moving the mesh with it) and move the mesh-offset back down via the green circle.
YasinB Hello again, I tried as you mentioned. I calculated the scaled mesh offset. It gave the correct result. However, I could not find a method or property to set the mesh offset for SkeletonGraphic. The SkeletonGraphic.SetScaledPivotOffset method is only valid in UnityEditor. Since the skeleton is created at runtime, I cannot prepare it as a prefab. Is there a shared property or method to set the mesh offset? Or should I offset it by changing the Skeleton.X and Skeleton.Y values?
YasinB I was able to change the pivot and position the mesh using bounds with the following method. Thanks for help. skeletonGraphic.rectTransform.pivot = new Vector2(0.5, 0.5); skeletonOffset = -bounds.center / SkeletonGraphic.MeshScale; Skeleton.X += skeletonOffset.x; Skeleton.Y += skeletonOffset.y; SkeletonGraphic.UpdateMesh();
Harald @YasinB That's a valid point. We've exposed SkeletonGraphic.SetScaledPivotOffset outside of the Unity Editor as well via this commit. A new spine-unity 4.2 package is available for download: https://esotericsoftware.com/spine-unity-download Thanks for reporting!