I have a sprite attached to a canvas. The sprite is of Transform type, while 3 other canvas elements are of Rect Transform type.
I want my sprite to show atop of the Rect Transforms. This seems no problem, however, in the Scene, where I merely set the sort layer to 1 (at “0” it is behind the Rects). They are all in the same layer “UI”.
Now, I click the play button. I see all the rects, they do all they are supposed to, but the sprite is nowhere to be seen. If I disable all the others, the sprite neither shows up, leaving me to believe it is simply not present at all.
Can anyone explain this? And how to solve it?
Perhaps your canvas rendering mode effects this, try changing (click on canvas in inspector) the setting from whatever it’s on to screen space - overlay. If it’s already overlay, maybe the transform is wrong and it moves it from where you think it should be to a spot off screen. Where is it when you run the game, pause the editor, and look at the canvas? Does the canvas / ui element move?
Then again I’m guessing, could be something different.
Edit: wait do you mean a sprite gameobject that’s a child of the canvas (if so disregard prior advice)? What is the purpose of that? You want it “in front” of the gui?
Edit2: maybe you could just use an “image” in the new gui for this depending what your doing. But then you need to adjust it to appear over the other elements, which I can’t remember off the top of my head how that is done.
Big changes.
It’s now an animation instead, and it’s not attached to the canvas. I just had it there because it felt appropriate at the time.
Anyways, when I play the game, the values don’t move. Since it’s now an animation, I don’t think it vice to somehow convert it to an image, but pray tell me if I’m wrong.
And yes, I want it to be atop of the GUI.
Well. I’m not sure exactly how it works but it’s just been my understanding that the new gui draws over all gameobjects/sprites/anything not in the canvas (or another canvas). So I can’t really tell you what to try or if there’s a way to make go’s or sprites render on top of the ui, but I can tell you that an “image” in the new canvas is just like a button or any other element of the ui, except without interaction from the user. It seems like it’s designed with purposes like titles above interactive sliders or things that you don’t interact with in the ui but need there graphically. I’d say it’s your best bet using an image (create > ui > image… or similar) to allow something to draw on top of the gui (there’s more work to decide which ui elements draw on top of which other ui elements) - but that wouldn’t be ideal for characters or anything that won’t be just an overlay of the actual 3d or 2d gameobjects/sprites. If I’m wrong about any of that somebody please correct me!
Good luck!
Images can’t be animated, can they?
I’m not sure. Maybe start a post on unity answers about that, someone must have tried before.