OverviewUIPanel is a component that collects and manages all widgets underneath it. UIPanel is responsible for creating the actual draw calls using the widget's geometry. Without panels, nothing can be drawn. If you're familiar with Unity, you can think of a UIPanel as a Renderer.
UIPanel inherits all the functionality of its base class --
UIRect.
All panels have a
Depth value which affects all widgets underneath. If you're creating a complex UI with multiple windows, it's often best to have one UIPanel per window. The depth value of panels carries a lot more weight than the depth value on individual widgets, so it's a good idea to ensure that your panels don't share depth values. If values get shared, draw calls will start to get split up frequently in order to preserve the draw order, resulting in a lot more draw calls than usual.
- Alpha property affects all the widgets underneath. It's a good way to fade out an entire window.
- If your UI is affected by lighting, be sure to check the Normals checkbox.
- If you are creating a scrollable panel that has a lot of geometry inside, you may want to toggle the Cull option in order to reduce the number of triangles drawn. Note that doing so may actually reduce performance, however (as the visibility of widgets will need to be checked every update!).
- Checking the Static checkbox will improve performance by telling NGUI that widgets underneath this panel are not expected to move. NGUI will bypass checking for position/rotation/scale changes. Note that doing so means that moving widgets at run-time will not have any effect, however -- so be careful.
- If you are trying to debug draw calls created by the panels, Show All option may help you. Doing so will let you see all the draw calls created by NGUI's panels in the order that they are drawn. Each draw call shows detailed information including the material used, which widgets are contributing to it, and even let you turn off the draw calls selectively in order to help you determine what's going on.
The panels can automatically
Clip all children using the dimensions of your choice. To enable clipping, just choose one of the options under the
Clipping drop-down, then adjust the dimensions of the purple rectangle in the Scene View like you would adjust the dimensions of any widget. If you're going down that route you can turn your panel into a
Scroll View and make it draggable fairly easily as well.
In NGUI 3.5.5 and earlier versions, multiple clipped panels would not work. Only the last panel would clip the contents. This limitation was lifted in NGUI 3.5.6.
By default, all of NGUI's panels will begin drawing with Render Queues of 3000 and go up from there. You can change that by choosing something under the
Render Q drop-down list. If you want to add a particle system in between of two of your panels, simply make sure that the first panel's render queue is lower than the one used by the particle system's material, and the second one has it set to a higher than the particle system. If you want NGUI 2.X-like behaviour where all draw calls were Z-based instead of depth-based, specify an
Explicit render queue (3000 is what NGUI 2.X used).
If you are looking for the documentation regarding the
Anchors section, you can find it in the base class --
UIRect.
Pro-TipA kinematic Rigidbody gets added to your panels automatically because according to Unity this greatly improves performance in physics-heavy games. Moving static colliders is a very expensive operation in Unity, but moving rigidbodies is not.
Class Documentationhttp://tasharen.com/ngui/docs/class_u_i_panel.htmlIf you have a question regarding this component or would like me to clarify something, just post a reply here.