NGUI: Next-Gen UI kit
3.7.2
|
UI Panel is responsible for collecting, sorting and updating widgets in addition to generating widgets' geometry. More...
Public Types | |
enum | RenderQueue { RenderQueue.Automatic, RenderQueue.StartAt, RenderQueue.Explicit } |
![]() | |
enum | AnchorUpdate { AnchorUpdate.OnEnable, AnchorUpdate.OnUpdate, AnchorUpdate.OnStart } |
Public Member Functions | |
delegate void | OnGeometryUpdated () |
delegate void | OnClippingMoved (UIPanel panel) |
override Vector3[] | GetSides (Transform relativeTo) |
Get the sides of the rectangle relative to the specified transform. The order is left, top, right, bottom. More... | |
override void | Invalidate (bool includeChildren) |
Invalidating the panel should reset its alpha. More... | |
override float | CalculateFinalAlpha (int frameID) |
Widget's final alpha, after taking the panel's alpha into account. More... | |
override void | SetRect (float x, float y, float width, float height) |
Set the panel's rectangle. More... | |
bool | IsVisible (Vector3 a, Vector3 b, Vector3 c, Vector3 d) |
Returns whether the specified rectangle is visible by the panel. The coordinates must be in world space. More... | |
bool | IsVisible (Vector3 worldPos) |
Returns whether the specified world position is within the panel's bounds determined by the clipping rect. More... | |
bool | IsVisible (UIWidget w) |
Returns whether the specified widget is visible by the panel. More... | |
bool | Affects (UIWidget w) |
Whether the specified widget is going to be affected by this panel in any way. More... | |
void | RebuildAllDrawCalls () |
Causes all draw calls to be re-created on the next update. More... | |
void | SetDirty () |
Invalidate the panel's draw calls, forcing them to be rebuilt on the next update. This call also affects all children. More... | |
override void | ParentHasChanged () |
Find the parent panel, if we have one. More... | |
void | SortWidgets () |
Immediately sort all child widgets. More... | |
UIDrawCall | FindDrawCall (UIWidget w) |
Insert the specified widget into one of the existing draw calls if possible. If it's not possible, and a new draw call is required, 'null' is returned because draw call creation is a delayed operation. More... | |
void | AddWidget (UIWidget w) |
Make the following widget be managed by the panel. More... | |
void | RemoveWidget (UIWidget w) |
Remove the widget from its current draw call, invalidating everything as needed. More... | |
void | Refresh () |
Immediately refresh the panel. More... | |
virtual Vector3 | CalculateConstrainOffset (Vector2 min, Vector2 max) |
Calculate the offset needed to be constrained within the panel's bounds. More... | |
bool | ConstrainTargetToBounds (Transform target, ref Bounds targetBounds, bool immediate) |
Constrain the current target position to be within panel bounds. More... | |
bool | ConstrainTargetToBounds (Transform target, bool immediate) |
Constrain the specified target to be within the panel's bounds. More... | |
Vector2 | GetViewSize () |
Panel's size – which is either the clipping rect, or the screen dimensions. More... | |
![]() | |
void | Update () |
Rectangles need to update in a specific order – parents before children. When deriving from this class, override its OnUpdate() function instead. More... | |
void | UpdateAnchors () |
Manually update anchored sides. More... | |
void | SetAnchor (Transform t) |
Anchor this rectangle to the specified transform. Note that this function will not keep the rectangle's current dimensions, but will instead assume the target's dimensions. More... | |
void | SetAnchor (GameObject go) |
Anchor this rectangle to the specified transform. Note that this function will not keep the rectangle's current dimensions, but will instead assume the target's dimensions. More... | |
void | SetAnchor (GameObject go, int left, int bottom, int right, int top) |
Anchor this rectangle to the specified transform. More... | |
void | ResetAnchors () |
Ensure that all rect references are set correctly on the anchors. More... | |
void | ResetAndUpdateAnchors () |
Convenience method that resets and updates the anchors, all at once. More... | |
Static Public Member Functions | |
static int | CompareFunc (UIPanel a, UIPanel b) |
Function that can be used to depth-sort panels. More... | |
static UIPanel | Find (Transform trans) |
Find the UIPanel responsible for handling the specified transform. More... | |
static UIPanel | Find (Transform trans, bool createIfMissing) |
Find the UIPanel responsible for handling the specified transform. More... | |
static UIPanel | Find (Transform trans, bool createIfMissing, int layer) |
Find the UIPanel responsible for handling the specified transform. More... | |
Public Attributes | |
OnGeometryUpdated | onGeometryUpdated |
Notification triggered when the panel's geometry get rebuilt. It's mainly here for debugging purposes. More... | |
bool | showInPanelTool = true |
Whether this panel will show up in the panel tool (set this to 'false' for dynamically created temporary panels) More... | |
bool | generateNormals = false |
Whether normals and tangents will be generated for all meshes More... | |
bool | widgetsAreStatic = false |
Whether widgets drawn by this panel are static (won't move). This will improve performance. More... | |
bool | cullWhileDragging = true |
Whether widgets will be culled while the panel is being dragged. Having this on improves performance, but turning it off will reduce garbage collection. More... | |
bool | alwaysOnScreen = false |
Optimization flag. Makes the assumption that the panel's geometry will always be on screen and the bounds don't need to be re-calculated. More... | |
bool | anchorOffset = false |
By default, non-clipped panels use the camera's bounds, and the panel's position has no effect. If you want the panel's position to actually be used with anchors, set this field to 'true'. More... | |
bool | softBorderPadding = true |
Whether the soft border will be used as padding. More... | |
RenderQueue | renderQueue = RenderQueue.Automatic |
By default all panels manage render queues of their draw calls themselves by incrementing them so that the geometry is drawn in the proper order. You can alter this behaviour. More... | |
int | startingRenderQueue = 3000 |
Render queue used by the panel. The default value of '3000' is the equivalent of "Transparent". This property is only used if 'renderQueue' is set to something other than "Automatic". More... | |
List< UIWidget > | widgets = new List<UIWidget>() |
List of widgets managed by this panel. Do not attempt to modify this list yourself. More... | |
List< UIDrawCall > | drawCalls = new List<UIDrawCall>() |
List of draw calls created by this panel. Do not attempt to modify this list yourself. More... | |
Matrix4x4 | worldToLocal = Matrix4x4.identity |
Matrix that will transform the specified world coordinates to relative-to-panel coordinates. More... | |
Vector4 | drawCallClipRange = new Vector4(0f, 0f, 1f, 1f) |
Cached clip range passed to the draw call's shader. More... | |
OnClippingMoved | onClipMove |
Event callback that's triggered when the panel's clip region gets moved. More... | |
![]() | |
AnchorPoint | leftAnchor = new AnchorPoint() |
Left side anchor. More... | |
AnchorPoint | rightAnchor = new AnchorPoint(1f) |
Right side anchor. More... | |
AnchorPoint | bottomAnchor = new AnchorPoint() |
Bottom side anchor. More... | |
AnchorPoint | topAnchor = new AnchorPoint(1f) |
Top side anchor. More... | |
AnchorUpdate | updateAnchors = AnchorUpdate.OnUpdate |
Whether anchors will be recalculated on every update. More... | |
float | finalAlpha = 1f |
Final calculated alpha. More... | |
Static Public Attributes | |
static List< UIPanel > | list = new List<UIPanel>() |
List of active panels. More... | |
Protected Member Functions | |
override void | OnStart () |
Layer is used to ensure that if it changes, widgets get moved as well. More... | |
override void | OnEnable () |
Reset the frame IDs. More... | |
override void | OnValidate () |
override void | OnInit () |
Mark all widgets as having been changed so the draw calls get re-created. More... | |
override void | OnDisable () |
Destroy all draw calls we've created when this script gets disabled. More... | |
override void | OnAnchor () |
Update the edges after the anchors have been updated. More... | |
![]() | |
Vector3 | GetLocalPos (AnchorPoint ac, Transform trans) |
Helper function that gets the specified anchor's position relative to the chosen transform. More... | |
void | Start () |
Set anchor rect references on start. More... | |
virtual void | OnUpdate () |
Abstract update functionality, ensured to happen after the targeting anchors have been updated. More... | |
Properties | |
static int | nextUnusedDepth [get] |
Helper property that returns the first unused depth value. More... | |
override bool | canBeAnchored [get] |
Whether the rectangle can be anchored. More... | |
override float | alpha [get, set] |
Panel's alpha affects everything drawn by the panel. More... | |
int | depth [get, set] |
Panels can have their own depth value that will change the order with which everything they manage gets drawn. More... | |
int | sortingOrder [get, set] |
Sorting order value for the panel's draw calls, to be used with Unity's 2D system. More... | |
float | width [get] |
Panel's width in pixels. More... | |
float | height [get] |
Panel's height in pixels. More... | |
bool | halfPixelOffset [get] |
Whether the panel's drawn geometry needs to be offset by a half-pixel. More... | |
bool | usedForUI [get] |
Whether the camera is used to draw UI geometry. More... | |
Vector3 | drawCallOffset [get] |
Directx9 pixel offset, used for drawing. More... | |
UIDrawCall.Clipping | clipping [get, set] |
Clipping method used by all draw calls. More... | |
UIPanel | parentPanel [get] |
Reference to the parent panel, if any. More... | |
int | clipCount [get] |
Number of times the panel's contents get clipped. More... | |
bool | hasClipping [get] |
Whether the panel will actually perform clipping of children. More... | |
bool | hasCumulativeClipping [get] |
Whether the panel will actually perform clipping of children. More... | |
bool | clipsChildren [get] |
Vector2 | clipOffset [get, set] |
Clipping area offset used to make it possible to move clipped panels (scroll views) efficiently. Scroll views move by adjusting the clip offset by one value, and the transform position by the inverse. This makes it possible to not have to rebuild the geometry, greatly improving performance. More... | |
Vector4 | clipRange [get, set] |
Clipping position (XY) and size (ZW). Note that you should not be modifying this property at run-time to reposition the clipping. Adjust clipOffset instead. More... | |
Vector4 | baseClipRegion [get, set] |
Clipping position (XY) and size (ZW). Note that you should not be modifying this property at run-time to reposition the clipping. Adjust clipOffset instead. More... | |
Vector4 | finalClipRegion [get] |
Final clipping region after the offset has been taken into consideration. XY = center, ZW = size. More... | |
Vector2 | clipSoftness [get, set] |
Clipping softness is used if the clipped style is set to "Soft". More... | |
override Vector3[] | localCorners [get] |
Local-space corners of the panel's clipping rectangle. The order is bottom-left, top-left, top-right, bottom-right. More... | |
override Vector3[] | worldCorners [get] |
World-space corners of the panel's clipping rectangle. The order is bottom-left, top-left, top-right, bottom-right. More... | |
![]() | |
GameObject | cachedGameObject [get] |
Game object gets cached for speed. Can't simply return 'mGo' set in Awake because this function may be called on a prefab. More... | |
Transform | cachedTransform [get] |
Transform gets cached for speed. Can't simply return 'mTrans' set in Awake because this function may be called on a prefab. More... | |
Camera | anchorCamera [get] |
Camera used by anchors. More... | |
bool | isFullyAnchored [get] |
Whether the rectangle is currently anchored fully on all sides. More... | |
virtual bool | isAnchoredHorizontally [get] |
Whether the rectangle is anchored horizontally. More... | |
virtual bool | isAnchoredVertically [get] |
Whether the rectangle is anchored vertically. More... | |
virtual bool | canBeAnchored [get] |
Whether the rectangle can be anchored. More... | |
UIRect | parent [get] |
Get the rectangle's parent, if any. More... | |
UIRoot | root [get] |
Get the root object, if any. More... | |
bool | isAnchored [get] |
Returns 'true' if the widget is currently anchored on any side. More... | |
abstract float | alpha [get, set] |
Local alpha, not relative to anything. More... | |
abstract Vector3[] | localCorners [get] |
Local-space corners of the UI rectangle. The order is bottom-left, top-left, top-right, bottom-right. More... | |
abstract Vector3[] | worldCorners [get] |
World-space corners of the UI rectangle. The order is bottom-left, top-left, top-right, bottom-right. More... | |
float | cameraRayDistance [get] |
Helper function that returns the distance to the camera's directional vector hitting the panel's plane. More... | |
Additional Inherited Members | |
![]() | |
GameObject | mGo |
Transform | mTrans |
BetterList< UIRect > | mChildren = new BetterList<UIRect>() |
bool | mChanged = true |
bool | mStarted = false |
bool | mParentFound = false |
Camera | mCam |
![]() | |
static Vector3[] | mSides = new Vector3[4] |
UI Panel is responsible for collecting, sorting and updating widgets in addition to generating widgets' geometry.
enum UIPanel.RenderQueue |
void UIPanel.AddWidget | ( | UIWidget | w | ) |
Make the following widget be managed by the panel.
bool UIPanel.Affects | ( | UIWidget | w | ) |
Whether the specified widget is going to be affected by this panel in any way.
|
virtual |
Calculate the offset needed to be constrained within the panel's bounds.
|
virtual |
Widget's final alpha, after taking the panel's alpha into account.
Implements UIRect.
Function that can be used to depth-sort panels.
bool UIPanel.ConstrainTargetToBounds | ( | Transform | target, |
ref Bounds | targetBounds, | ||
bool | immediate | ||
) |
Constrain the current target position to be within panel bounds.
bool UIPanel.ConstrainTargetToBounds | ( | Transform | target, |
bool | immediate | ||
) |
Constrain the specified target to be within the panel's bounds.
|
static |
Find the UIPanel responsible for handling the specified transform.
|
static |
Find the UIPanel responsible for handling the specified transform.
|
static |
Find the UIPanel responsible for handling the specified transform.
UIDrawCall UIPanel.FindDrawCall | ( | UIWidget | w | ) |
Insert the specified widget into one of the existing draw calls if possible. If it's not possible, and a new draw call is required, 'null' is returned because draw call creation is a delayed operation.
|
virtual |
Get the sides of the rectangle relative to the specified transform. The order is left, top, right, bottom.
Reimplemented from UIRect.
Vector2 UIPanel.GetViewSize | ( | ) |
Panel's size – which is either the clipping rect, or the screen dimensions.
|
virtual |
Invalidating the panel should reset its alpha.
Reimplemented from UIRect.
bool UIPanel.IsVisible | ( | Vector3 | a, |
Vector3 | b, | ||
Vector3 | c, | ||
Vector3 | d | ||
) |
Returns whether the specified rectangle is visible by the panel. The coordinates must be in world space.
bool UIPanel.IsVisible | ( | Vector3 | worldPos | ) |
Returns whether the specified world position is within the panel's bounds determined by the clipping rect.
bool UIPanel.IsVisible | ( | UIWidget | w | ) |
Returns whether the specified widget is visible by the panel.
|
protectedvirtual |
Update the edges after the anchors have been updated.
Implements UIRect.
delegate void UIPanel.OnClippingMoved | ( | UIPanel | panel | ) |
|
protectedvirtual |
Destroy all draw calls we've created when this script gets disabled.
Reimplemented from UIRect.
|
protectedvirtual |
Reset the frame IDs.
Reimplemented from UIRect.
delegate void UIPanel.OnGeometryUpdated | ( | ) |
|
protectedvirtual |
Mark all widgets as having been changed so the draw calls get re-created.
Reimplemented from UIRect.
|
protectedvirtual |
Layer is used to ensure that if it changes, widgets get moved as well.
Implements UIRect.
|
protected |
|
virtual |
Find the parent panel, if we have one.
Reimplemented from UIRect.
void UIPanel.RebuildAllDrawCalls | ( | ) |
Causes all draw calls to be re-created on the next update.
void UIPanel.Refresh | ( | ) |
Immediately refresh the panel.
void UIPanel.RemoveWidget | ( | UIWidget | w | ) |
Remove the widget from its current draw call, invalidating everything as needed.
void UIPanel.SetDirty | ( | ) |
Invalidate the panel's draw calls, forcing them to be rebuilt on the next update. This call also affects all children.
|
virtual |
Set the panel's rectangle.
Implements UIRect.
void UIPanel.SortWidgets | ( | ) |
Immediately sort all child widgets.
bool UIPanel.alwaysOnScreen = false |
Optimization flag. Makes the assumption that the panel's geometry will always be on screen and the bounds don't need to be re-calculated.
bool UIPanel.anchorOffset = false |
By default, non-clipped panels use the camera's bounds, and the panel's position has no effect. If you want the panel's position to actually be used with anchors, set this field to 'true'.
bool UIPanel.cullWhileDragging = true |
Whether widgets will be culled while the panel is being dragged. Having this on improves performance, but turning it off will reduce garbage collection.
Vector4 UIPanel.drawCallClipRange = new Vector4(0f, 0f, 1f, 1f) |
Cached clip range passed to the draw call's shader.
List<UIDrawCall> UIPanel.drawCalls = new List<UIDrawCall>() |
List of draw calls created by this panel. Do not attempt to modify this list yourself.
bool UIPanel.generateNormals = false |
Whether normals and tangents will be generated for all meshes
OnClippingMoved UIPanel.onClipMove |
Event callback that's triggered when the panel's clip region gets moved.
OnGeometryUpdated UIPanel.onGeometryUpdated |
Notification triggered when the panel's geometry get rebuilt. It's mainly here for debugging purposes.
RenderQueue UIPanel.renderQueue = RenderQueue.Automatic |
By default all panels manage render queues of their draw calls themselves by incrementing them so that the geometry is drawn in the proper order. You can alter this behaviour.
bool UIPanel.showInPanelTool = true |
Whether this panel will show up in the panel tool (set this to 'false' for dynamically created temporary panels)
bool UIPanel.softBorderPadding = true |
Whether the soft border will be used as padding.
int UIPanel.startingRenderQueue = 3000 |
Render queue used by the panel. The default value of '3000' is the equivalent of "Transparent". This property is only used if 'renderQueue' is set to something other than "Automatic".
List of widgets managed by this panel. Do not attempt to modify this list yourself.
bool UIPanel.widgetsAreStatic = false |
Whether widgets drawn by this panel are static (won't move). This will improve performance.
Matrix4x4 UIPanel.worldToLocal = Matrix4x4.identity |
Matrix that will transform the specified world coordinates to relative-to-panel coordinates.
|
getset |
Panel's alpha affects everything drawn by the panel.
|
getset |
Clipping position (XY) and size (ZW). Note that you should not be modifying this property at run-time to reposition the clipping. Adjust clipOffset instead.
|
get |
Whether the rectangle can be anchored.
|
get |
Number of times the panel's contents get clipped.
|
getset |
Clipping area offset used to make it possible to move clipped panels (scroll views) efficiently. Scroll views move by adjusting the clip offset by one value, and the transform position by the inverse. This makes it possible to not have to rebuild the geometry, greatly improving performance.
|
getset |
Clipping method used by all draw calls.
|
getset |
Clipping position (XY) and size (ZW). Note that you should not be modifying this property at run-time to reposition the clipping. Adjust clipOffset instead.
|
get |
|
getset |
Clipping softness is used if the clipped style is set to "Soft".
|
getset |
Panels can have their own depth value that will change the order with which everything they manage gets drawn.
|
get |
Directx9 pixel offset, used for drawing.
|
get |
Final clipping region after the offset has been taken into consideration. XY = center, ZW = size.
|
get |
Whether the panel's drawn geometry needs to be offset by a half-pixel.
|
get |
Whether the panel will actually perform clipping of children.
|
get |
Whether the panel will actually perform clipping of children.
|
get |
Panel's height in pixels.
|
get |
Local-space corners of the panel's clipping rectangle. The order is bottom-left, top-left, top-right, bottom-right.
|
staticget |
Helper property that returns the first unused depth value.
|
get |
Reference to the parent panel, if any.
|
getset |
Sorting order value for the panel's draw calls, to be used with Unity's 2D system.
|
get |
Whether the camera is used to draw UI geometry.
|
get |
Panel's width in pixels.
|
get |
World-space corners of the panel's clipping rectangle. The order is bottom-left, top-left, top-right, bottom-right.