- Home /
GUI area vs group
In the GUI, there are groups and areas. What's the difference? The documentation says that areas can't be nested, but the same note does not appear on the group.
I created some test code to see if groups could be nested. It seemed to work. I tried it with areas, which also seemed to work. Is the documentation out of date?
Can someone tell if its safe to nest either/both, and what is the difference between the two.
Thanks.
Answer by Bunny83 · Sep 22, 2011 at 01:04 AM
GUI.BeginGroup and GUILayout.BeginArea is something totally different. As you might have noticed BeginGroup belongs to GUI and BeginArea to GUILayout.
The GUI functions always need a Rect to be given by the user. Groups just create a clipping area where the containing controls are displayed. The origin is "shifted" to the group's top-left coordinate. Those can be nested if you want to implement your own scrolling view or whatever.
GUILayout always uses automatic layouting. By default the whole screen is the layouting area. With BeginArea you can start a new layouting area at a certain screen coordinate. In most cases it doesn't make much sense to nest these areas since the content is layouted into this area. They just allow you to combine GUI with GUILayout stuff.