I have an editor window that draws a dynamic tree hierarchy, where each node is a GUI.Box, after that in the code I draw the connecting accordion lines. As you can see the lines are drawn in front of the tiles.
This is happening in a single script.
I moved the drawing of the tiles after the drawing of the lines, but it didnt work.
I tried GUI.depth, didnt work.
Edit:
What Im doing in code is:
foreach(allTiles) {
if(something) {
drawConnectinglines()
}
drawTileAndItsContent
}
Now Itried seperating the tile draw and line draw in different loops:
foreach(allTiles) {
if(something) {
drawConnectinglines()
}
}
foreach(allTiles) {
drawTileAndItsContent
}
The result is that now the lines are behind the buttons in the tiles, but infront of them:


1. GUI.depth only works between scripts, not inside the same script. 2. If the buttons and tiles should be drawn later (over) the lines, call their drawing code after the line drawing code. 3. Do you use EditorGUI functions for all the drawing?
– Cherno