private bool MatchRectTransformWithBounds_lowVersionCompatablity(SkeletonGraphic skeletonGraphic) { skeletonGraphic.UpdateMesh(); Mesh mesh = skeletonGraphic.GetLastMesh(); if (mesh == null) { return(false); } if (mesh.vertexCount == 0) { skeletonGraphic.rectTransform.sizeDelta = new Vector2(50f, 50f); skeletonGraphic.rectTransform.pivot = new Vector2(0.5f, 0.5f); return(false); } mesh.RecalculateBounds(); var bounds = mesh.bounds; var size = bounds.size; var center = bounds.center; var p = new Vector2( 0.5f - (center.x / size.x), 0.5f - (center.y / size.y) ); skeletonGraphic.rectTransform.sizeDelta = size; skeletonGraphic.rectTransform.pivot = p; return(true); }
void LateUpdate() { skeletonGraphic.UpdateMesh(); }