- Home /
how is it decided that which panel should be on top of another ?
so theres 1canvas that houses all the buttons in the scene, like running and jumping and everything else
different scene has different buttons so every scene has 1canvas
there is another canvas that has a panel that houses buttons like go back to main menu, save the progress, load last save game, etc
these buttons are same no matter what scene user is in, so anotherCanvas has DontDestroyOnLoad function on it
and panel stays inactive in scene untill user presses back button and than panel pops up with save, load, exit buttons
now heres the problem.
panel does pop up but it stays behind buttons in 1canvas
so when user presses back button, save,load,exit buttons does appear, but jump,run buttons stay on top of them.
how do I make it right ?
Things I tried
putting anotherCanvas below 1canvas - but that thing only works for things within a canvas, not for different canvases
SetAsLastSibling() SetAsFirstSibling() - but it only works for things within the canvas, not for things from another canvas
change transform.position.z of panel of anotherCanvas - from script, I made z value of panel (because z value of canvas doesnt change) from 0 to 1, so it does appear on top in SceneView, but in GameView it appears behind canvas1
Answer by Rexidecimal · Sep 02, 2018 at 08:25 AM
Have you tried modifying the sort order? If you put the back menu canvas as a higher sort order it should appear on top of the other canvas ex. game as 0, back menu as 1
Answer by Momcat · Sep 02, 2018 at 06:03 AM
It should be that the items that are listed in the hierarchy first are the first to appear, and each item listed after that should appear on top of it. So if your hierarchy says: Canvas1 Canvas2 Canvas3
then the order they should appear in the game view is, Canvas1 in the background, Canvas2 in the middle, and canvas3 on the very top.
Is that what you're asking?
Also you can always disable the conflicting canvas temporarily.
hi, thanks for the reply.
unfortunately, it doesnt work.
there are 2 canvases, canvas1 is scene specific, canvas2 is common among scene and has dontdestroyonload function attached to it. so obviously when scene starts scene specific canvas1 is already there and canvas2 is born afterwords. so it should come on top, but it doesnt.
Your answer
Follow this Question
Related Questions
Screen to canvas space 2 Answers
Fit application to any device resolution 1 Answer
Scaling Canvas (or panel) and then trying to move a gameobject (child) attached to it 1 Answer
[4.6 GUI] Displaying my pause menu when ESC is pressed 2 Answers
[Solved]Why my Unity Button's Positions are different. 1 Answer