This is my inventory menu screen. I've got a method which creates a box where the cursor is, while it's over a weapon image (this semi-transparent box with 'Berdysz 70'). The problem is that each item (so a button, weapon pic, some strings etc) and it's fluff box is generated via a for loop. Therefore every next item is being showed over each previous GUI element.
Is there a way to make a GUI elements - in my case this window, always on top?
Answer by Bunny83
Aug 16, 2011 at 07:39 PM
Yes there is a way, you need to draw it after your for loop. The GUI system is an immediate system, what is drawn at last will show on top. But be careful, the input handling works the other way round: what is drawn first will receive the input. Without the code i can't give you any hints for your case.
Another way is to use a GUI.Window. Windows are drawn above the normal gui stuff and have their own z-ordering system.
Answer by TowerOfBricks
Aug 16, 2011 at 07:42 PM
You can use GUI.depth, it usually works.
The thing is GUI.depth works for different classes only, not GUI elements inside one class - which is my case. and Since my showBox method takes parameters from inside of the for loop it's in, it's impossible to throw it out.
@4illeen: It's not impossible, you just need to store the condition / event / data and use it after the for loop. But as i said without the code it's useless to suggest a certain method / solution.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
4 People are following this question.
where to get GUI.box as a CANVAS Panel?
How Do I make a Note Taking Box?
Text and texture in GUI?
Write Text On Screen at Position
GUI.Box and GUI.BeginGroup are not part of GUI