- Изменено
How to get Bounds of Spine Animation object
Hi there.
I will start by saying that im a noob in Spine.
On my project im trying to change the size of UI parent object depending on size of its child with Spine Animation. From my research I understood that there is no predefined size of animation object, so you have to calculate yourself. Is there a idea how to do it, or maybe an example code for it?
About animation.
I have a library, you may say, of all animations of character generated on screen. Most of animations are "centered". But there are few that are kind of shifted to the right or left, and don't fit my predefined size of slot (that holds the animation)
I hope I explained alright.
Did I understand you right that you are using SkeletonGraphic
as child of a Unity UI element (RectTransform
)?
If you are, then you could use skeletonGraphic.MatchRectTransformWithBounds()
to update the RectTransform
to the mesh bounds.
If you are not using SkeletonGraphic
, or updating the RectTransform
does not help, you could extract the mesh bounds as shown a few lines below in the same method, using the following code:
mesh.RecalculateBounds();
Bounds bounds = mesh.bounds;