- Edited
Spine and Mecanim in UI
Hello,
I would like to get some clarification/insight on using a Spine object within a Unity canvas.
As far as I know, we have two options here (please note this is using a "Screen space : Camera” ):
-We can use the recommended SkeletonGraphic(UI) but we can’t use the mecanim system with it. On the flip side, it is displayed as a UI element straight out of the box.
-Alternatively, i have tried using the regular SkeletonMecanim system we use extensively in our game in a Canvas.
In the latest case, i've added a Rect Transform component on it (this is used to anchor the element, the spine object here, correctly on screen). Also, i've changed the sorting layer to UI and set a Pos Z of -1 in the Rect Transform values. This seems to work fine.
My question is the following: the SkeletonMecanim spine object uses a mesh renderer (which should not render in UI space) but Unity might assumes it's purely 2D because of the RectTransform component added on top and therefore render it. Can you tell me if this is a no-no way of doing things or can it work without any major issues?
Please note that while it is placed at the desired position (and the position is updated by the UI system) and at the correct depth / draw order, it is still rendered as a non-UI MeshRenderer
element. The RectTransform
just drives the position, it does not magically change the MeshRenderer
to a CanvasRenderer
. You will also not be able to use a Spine/Skeleton Graphic
shader on it. This means that any UI mask interactions (e.g. limiting the drawn sprite to the area of a parent with a Mask
component) will not work on the MeshRenderer
.
Apart from that, if you only need the render position and order, it should be fine when it's rendered as a MeshRenderer
.