3
\$\begingroup\$

I have two canvases. One with a background image and one with all overlaying elements like texts and such.

The background canvas has an order of 0, the overlay canvas of 1.

Now, I'd like to create an animating sprite on top of those canvases but I can't for the life of me get the sprite on top of the other images.

I can see the sprite being on top on the stage, but when I switch to gameview, it's gone! There are no scripts attached to the sprite. Only an animator(Which works fine when I play it).

Note:

  • My canvases have a render mode of Screen space - Overlay.
  • I've set the spriterenderer on Sorting Layer 9, order 300. Although it's the only sprite out there. layer 1 or order 1 didn't do anything different, though.
  • The other elements in the canvases are either UI texts or Images
  • All the elements in the canvases are on either BackgroundLayer or OverlayLayer
  • The canvases themselves are on the UI layer
\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

I'm sure there's an issue with Unity UI and the sprite renderer. UI elements tend to be drawn above everything else. One work-around is to render the UI and sprite renderer on separate cameras and then apply the depth settings to the cameras. This can negatively effect performance.

Edit: The 'best answer' here should tell you what you need to know.

\$\endgroup\$
0
\$\begingroup\$

Check if any of your UI elements has Transform component instead of RectTransform component. That could cause your sprites render in world space, not on UI layer.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .