OnGUI is always drawn on top of everything, including GUITextures. I think some kind of custom cursor function is necessary, where it’s not covered by anything.
The entire screen (including all my gui windows) gets blacked out nicely. As a side bonus, I can still click through the black box to interact with those windows.
Haven’t done any testing, but I am sure you could just make a custom cursor style and apply it instead of “box”.
Cool, didn’t think of that As far as I know, setting GUI.Depth to anything less than 1 will draw it over GUI.Windows. Interestingly the documentation doesn’t mention the overlap between OnGUI and GUI.Window depths.
Thanks guys… this depth thing sure is obscure and ill-documented!
I thought negative depth had no effect, I even filed a bug about this when 2.0 came out, maybe they changed it?
I sure wish they’d used the more traditional z-index convention… but if depth can be negative after all, the result is the same, so that’s cool
I don’t really understand that… you said earlier:
… which is it?
Anyway, it turns out I didn’t explicitly set GUI.depth in my mouse cursor script, assuming it would be 0 by default… but in fact, it seems that GUI.depth isn’t reset between scripts, so my cursor used the depth set by the last running script!
Now I’m setting it to 0 explicitly and my cursor does appear on top of my windows.
I’m filing a bug asking for clarification… let’s all file one to keep the pressure up
@Ben
So by default, everything you put in OnGUI renders behind windows, unless you specify a GUI.depth of less than 1, and then the controls immediately after the depth setting will appear over your windows. Sorry about the ambiguity.