JohnG

Hi guys,

I have a set of Spine exports which I am using in Unity with their UI system with SkeletonGraphic components, which for the most part work well.

The issue I am having is that the UI anchors don't seem to alter Spine elements in a similar fashion to built in Unity UI elements. An example of this is that if I have a 16:9 full screen object and I want this object to be anchored to 100% of the screen, when I switch to another resolution, say 18:9, the graphics do not resize to fit the screen size and will have a portion off the screen.

Is there a way I can get SkeletonGraphic components to respect the settings of the RectTransform anchors for the object they are attached to? Positional anchoring works without issue in respect to the RectTransform but all scaling is ignored.

Thanks,

John

---

An example can be seen here.

On the left is a Spine SkeletonGraphic anchored within the screen boundary, on the right is a Unity UI Image, anchored to a similar portion of the screen.

At 16:9 the top of the Spine object is within the screen and the image on the right is within the screen as can be seen below:

169.png


At 18:9 the top of the Spine object has left the top of the screen while the Unity UI Image on the right has maintained its position and scale to fall within the screen as can be seen below:

189.png


This functionality is essential to handling multiple devices (e.g. phones at 18:9 against tablets at 4:3 for example). If anyone has any input on how I could achieve the same effect with Spine objects I would appreciate it.

Thanks.
JohnG
Posts: 1

Pharan

You are correct. The skeleton's scale is unaffected by the RectTransform of the GameObject. Mostly because a skeleton doesn't actually have a fixed scale, unlike sprites. This is the same behavior you'd run into if you were to put a multi-GameObject character using Unity's own system, or other skeletal animation systems.

In the current implementation, we make no assumptions as to how the skeleton scale relates or behaves relative to the RectTransform's dimensions.

An additional component/script could probably be written to do this scaling. The script can have a base RectTransform size, watch the dimensions, then calculate and apply the appropriate scale for the skeleton. It would need to keep the RectTransform pivot in mind to align it properly with the pivot of the skeleton as it scales.
User avatar
Pharan

Pharan
Posts: 5281


Return to Unity
cron