I read the suggestion (somewhere) that the GUI elements should be on their own layer, with their own camera, separate from the game layer. Unfortunately, I can't find the post again. :) So I have two question about that.
First, why? What are the consequences of having the GUI on a separate layer? Assume that I write reasonably modular code, and all my GUI display elements are in one script (and they only set State variables that other scripts use).
Second, (and I hate to ask this :) but how? I have followed every step in the Unity Layers Guide. I have created a new Layer called GUI, and assigned my GUI_gameobject (called GuiTop) to that layer. Then I unchecked GUI on the main (only) Scene Camera Culling Mask. At this point, I am presuming that my GUI buttons would not be visible, since the only existing Camera is not supposed to display that layer. Yet they display...
The GuiTop is an empty GO that has a script attached - this script has the usual OnGUI() and GUI.Button() type statements. Is it sufficient for GuiTop to be assigned to the Layer GUI, or do I need to also do the script component?
Or is there some other step I'm missing?
Ah, I also removed the GUILayer component from the Camera, although as far as I can tell, this is only for GUITextures, shouldn't have an effect - and didn't.
asked Mar 18 '10 at 08:00 PM
1) I have no idea...toggling the GUILayer component will turn on and off all GUIElements anyway.
2) OnGUI is different from GUIElements, does not use the GUILayer camera component, and cannot be put on a separate layer. It's always drawn on top of everything.
answered Mar 18 '10 at 08:07 PM