NGUI: Next-Gen UI kit  3.7.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
UIRect Class Referenceabstract

Abstract UI rectangle containing functionality common to both panels and widgets. A UI rectangle contains 4 anchor points (one for each side), and it ensures that they are updated in the proper order. More...

Inheritance diagram for UIRect:
UIPanel UIWidget UIBasicSprite UILabel UI2DSprite UISprite UITexture

Classes

class  AnchorPoint
 

Public Types

enum  AnchorUpdate { AnchorUpdate.OnEnable, AnchorUpdate.OnUpdate, AnchorUpdate.OnStart }
 

Public Member Functions

abstract float CalculateFinalAlpha (int frameID)
 Get the final cumulative alpha. More...
 
virtual void Invalidate (bool includeChildren)
 Sets the local 'changed' flag, indicating that some parent value(s) are now be different, such as alpha for example. More...
 
virtual Vector3[] GetSides (Transform relativeTo)
 Get the sides of the rectangle relative to the specified transform. The order is left, top, right, bottom. 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...
 
abstract void SetRect (float x, float y, float width, float height)
 Set the rectangle manually. More...
 
virtual void ParentHasChanged ()
 Call this function when the rectangle's parent has changed. More...
 

Public Attributes

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...
 

Protected Member Functions

Vector3 GetLocalPos (AnchorPoint ac, Transform trans)
 Helper function that gets the specified anchor's position relative to the chosen transform. More...
 
virtual void OnEnable ()
 Automatically find the parent rectangle. More...
 
virtual void OnInit ()
 Automatically find the parent rectangle. More...
 
virtual void OnDisable ()
 Clear the parent rectangle reference. More...
 
void Start ()
 Set anchor rect references on start. More...
 
abstract void OnAnchor ()
 Update the dimensions of the rectangle using anchor points. More...
 
abstract void OnStart ()
 Abstract start functionality, ensured to happen after the anchor rect references have been set. More...
 
virtual void OnUpdate ()
 Abstract update functionality, ensured to happen after the targeting anchors have been updated. More...
 

Protected Attributes

GameObject mGo
 
Transform mTrans
 
BetterList< UIRectmChildren = new BetterList<UIRect>()
 
bool mChanged = true
 
bool mStarted = false
 
bool mParentFound = false
 
Camera mCam
 

Static Protected Attributes

static Vector3[] mSides = new Vector3[4]
 

Properties

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...
 

Detailed Description

Abstract UI rectangle containing functionality common to both panels and widgets. A UI rectangle contains 4 anchor points (one for each side), and it ensures that they are updated in the proper order.

Member Enumeration Documentation

Enumerator
OnEnable 
OnUpdate 
OnStart 

Member Function Documentation

abstract float UIRect.CalculateFinalAlpha ( int  frameID)
pure virtual

Get the final cumulative alpha.

Implemented in UIWidget, and UIPanel.

Vector3 UIRect.GetLocalPos ( AnchorPoint  ac,
Transform  trans 
)
protected

Helper function that gets the specified anchor's position relative to the chosen transform.

virtual Vector3 [] UIRect.GetSides ( Transform  relativeTo)
virtual

Get the sides of the rectangle relative to the specified transform. The order is left, top, right, bottom.

Reimplemented in UILabel, UIWidget, and UIPanel.

virtual void UIRect.Invalidate ( bool  includeChildren)
virtual

Sets the local 'changed' flag, indicating that some parent value(s) are now be different, such as alpha for example.

Reimplemented in UIWidget, and UIPanel.

abstract void UIRect.OnAnchor ( )
protectedpure virtual

Update the dimensions of the rectangle using anchor points.

Implemented in UIWidget, UIPanel, and UILabel.

virtual void UIRect.OnDisable ( )
protectedvirtual

Clear the parent rectangle reference.

Reimplemented in UIWidget, UIPanel, and UILabel.

virtual void UIRect.OnEnable ( )
protectedvirtual

Automatically find the parent rectangle.

Reimplemented in UIPanel, and UIWidget.

virtual void UIRect.OnInit ( )
protectedvirtual

Automatically find the parent rectangle.

Reimplemented in UIWidget, UIPanel, UILabel, and UISprite.

abstract void UIRect.OnStart ( )
protectedpure virtual

Abstract start functionality, ensured to happen after the anchor rect references have been set.

Implemented in UIWidget, UILabel, and UIPanel.

virtual void UIRect.OnUpdate ( )
protectedvirtual

Abstract update functionality, ensured to happen after the targeting anchors have been updated.

Reimplemented in UIWidget, UISprite, and UI2DSprite.

virtual void UIRect.ParentHasChanged ( )
virtual

Call this function when the rectangle's parent has changed.

Reimplemented in UIWidget, and UIPanel.

void UIRect.ResetAnchors ( )

Ensure that all rect references are set correctly on the anchors.

void UIRect.ResetAndUpdateAnchors ( )

Convenience method that resets and updates the anchors, all at once.

void UIRect.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.

void UIRect.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.

void UIRect.SetAnchor ( GameObject  go,
int  left,
int  bottom,
int  right,
int  top 
)

Anchor this rectangle to the specified transform.

abstract void UIRect.SetRect ( float  x,
float  y,
float  width,
float  height 
)
pure virtual

Set the rectangle manually.

Implemented in UIWidget, and UIPanel.

void UIRect.Start ( )
protected

Set anchor rect references on start.

void UIRect.Update ( )

Rectangles need to update in a specific order – parents before children. When deriving from this class, override its OnUpdate() function instead.

void UIRect.UpdateAnchors ( )

Manually update anchored sides.

Member Data Documentation

AnchorPoint UIRect.bottomAnchor = new AnchorPoint()

Bottom side anchor.

float UIRect.finalAlpha = 1f

Final calculated alpha.

AnchorPoint UIRect.leftAnchor = new AnchorPoint()

Left side anchor.

Camera UIRect.mCam
protected
bool UIRect.mChanged = true
protected
BetterList<UIRect> UIRect.mChildren = new BetterList<UIRect>()
protected
GameObject UIRect.mGo
protected
bool UIRect.mParentFound = false
protected
Vector3 [] UIRect.mSides = new Vector3[4]
staticprotected
bool UIRect.mStarted = false
protected
Transform UIRect.mTrans
protected
AnchorPoint UIRect.rightAnchor = new AnchorPoint(1f)

Right side anchor.

AnchorPoint UIRect.topAnchor = new AnchorPoint(1f)

Top side anchor.

AnchorUpdate UIRect.updateAnchors = AnchorUpdate.OnUpdate

Whether anchors will be recalculated on every update.

Property Documentation

abstract float UIRect.alpha
getset

Local alpha, not relative to anything.

Camera UIRect.anchorCamera
get

Camera used by anchors.

GameObject UIRect.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.

Transform UIRect.cachedTransform
get

Transform gets cached for speed. Can't simply return 'mTrans' set in Awake because this function may be called on a prefab.

float UIRect.cameraRayDistance
getprotected

Helper function that returns the distance to the camera's directional vector hitting the panel's plane.

virtual bool UIRect.canBeAnchored
get

Whether the rectangle can be anchored.

bool UIRect.isAnchored
get

Returns 'true' if the widget is currently anchored on any side.

virtual bool UIRect.isAnchoredHorizontally
get

Whether the rectangle is anchored horizontally.

virtual bool UIRect.isAnchoredVertically
get

Whether the rectangle is anchored vertically.

bool UIRect.isFullyAnchored
get

Whether the rectangle is currently anchored fully on all sides.

abstract Vector3 [] UIRect.localCorners
get

Local-space corners of the UI rectangle. The order is bottom-left, top-left, top-right, bottom-right.

UIRect UIRect.parent
get

Get the rectangle's parent, if any.

UIRoot UIRect.root
get

Get the root object, if any.

abstract Vector3 [] UIRect.worldCorners
get

World-space corners of the UI rectangle. The order is bottom-left, top-left, top-right, bottom-right.


The documentation for this class was generated from the following file: