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

All children added to the game object with this script will be repositioned to be on a grid of specified dimensions. If you want the cells to automatically set their scale based on the dimensions of their content, take a look at UITable. More...

Inheritance diagram for UIGrid:
UIWidgetContainer

Public Types

enum  Arrangement { Arrangement.Horizontal, Arrangement.Vertical }
 
enum  Sorting {
  Sorting.None, Sorting.Alphabetic, Sorting.Horizontal, Sorting.Vertical,
  Sorting.Custom
}
 

Public Member Functions

delegate void OnReposition ()
 
List< Transform > GetChildList ()
 Get the current list of the grid's children. More...
 
Transform GetChild (int index)
 Convenience method: get the child at the specified index. Note that if you plan on calling this function more than once, it's faster to get the entire list using GetChildList() instead. More...
 
int GetIndex (Transform trans)
 Get the index of the specified item. More...
 
void AddChild (Transform trans)
 Convenience method – add a new child. More...
 
void AddChild (Transform trans, bool sort)
 Convenience method – add a new child. Note that if you plan on adding multiple objects, it's faster to GetChildList() and modify that instead. More...
 
bool RemoveChild (Transform t)
 Remove the specified child from the list. Note that if you plan on removing multiple objects, it's faster to GetChildList() and modify that instead. More...
 
virtual void Reposition ()
 Recalculate the position of all elements within the grid, sorting them alphabetically if necessary. More...
 
void ConstrainWithinPanel ()
 Constrain the grid's content to be within the panel's bounds. More...
 

Static Public Member Functions

static int SortByName (Transform a, Transform b)
 
static int SortHorizontal (Transform a, Transform b)
 
static int SortVertical (Transform a, Transform b)
 

Public Attributes

Arrangement arrangement = Arrangement.Horizontal
 Type of arrangement – vertical or horizontal. More...
 
Sorting sorting = Sorting.None
 How to sort the grid's elements. More...
 
UIWidget.Pivot pivot = UIWidget.Pivot.TopLeft
 Final pivot point for the grid's content. More...
 
int maxPerLine = 0
 Maximum children per line. If the arrangement is horizontal, this denotes the number of columns. If the arrangement is vertical, this stands for the number of rows. More...
 
float cellWidth = 200f
 The width of each of the cells. More...
 
float cellHeight = 200f
 The height of each of the cells. More...
 
bool animateSmoothly = false
 Whether the grid will smoothly animate its children into the correct place. More...
 
bool hideInactive = true
 Whether to ignore the disabled children or to treat them as being present. More...
 
bool keepWithinPanel = false
 Whether the parent container will be notified of the grid's changes. More...
 
OnReposition onReposition
 Callback triggered when the grid repositions its contents. More...
 
System.Comparison< Transform > onCustomSort
 Custom sort delegate, used when the sorting method is set to 'custom'. More...
 

Protected Member Functions

virtual void Init ()
 Initialize the grid. Executed only once. More...
 
virtual void Start ()
 Cache everything and reset the initial position of all children. More...
 
virtual void Update ()
 Reset the position if necessary, then disable the component. More...
 
virtual void Sort (List< Transform > list)
 You can override this function, but in most cases it's easier to just set the onCustomSort delegate instead. More...
 
void ResetPosition (List< Transform > list)
 Reset the position of all child objects based on the order of items in the list. More...
 

Protected Attributes

bool mReposition = false
 
UIPanel mPanel
 
bool mInitDone = false
 

Properties

bool repositionNow [set]
 Reposition the children on the next Update(). More...
 

Detailed Description

All children added to the game object with this script will be repositioned to be on a grid of specified dimensions. If you want the cells to automatically set their scale based on the dimensions of their content, take a look at UITable.

Member Enumeration Documentation

Enumerator
Horizontal 
Vertical 
Enumerator
None 
Alphabetic 
Horizontal 
Vertical 
Custom 

Member Function Documentation

void UIGrid.AddChild ( Transform  trans)

Convenience method – add a new child.

void UIGrid.AddChild ( Transform  trans,
bool  sort 
)

Convenience method – add a new child. Note that if you plan on adding multiple objects, it's faster to GetChildList() and modify that instead.

void UIGrid.ConstrainWithinPanel ( )

Constrain the grid's content to be within the panel's bounds.

Transform UIGrid.GetChild ( int  index)

Convenience method: get the child at the specified index. Note that if you plan on calling this function more than once, it's faster to get the entire list using GetChildList() instead.

List<Transform> UIGrid.GetChildList ( )

Get the current list of the grid's children.

int UIGrid.GetIndex ( Transform  trans)

Get the index of the specified item.

virtual void UIGrid.Init ( )
protectedvirtual

Initialize the grid. Executed only once.

delegate void UIGrid.OnReposition ( )
bool UIGrid.RemoveChild ( Transform  t)

Remove the specified child from the list. Note that if you plan on removing multiple objects, it's faster to GetChildList() and modify that instead.

virtual void UIGrid.Reposition ( )
virtual

Recalculate the position of all elements within the grid, sorting them alphabetically if necessary.

void UIGrid.ResetPosition ( List< Transform >  list)
protected

Reset the position of all child objects based on the order of items in the list.

virtual void UIGrid.Sort ( List< Transform >  list)
protectedvirtual

You can override this function, but in most cases it's easier to just set the onCustomSort delegate instead.

static int UIGrid.SortByName ( Transform  a,
Transform  b 
)
static
static int UIGrid.SortHorizontal ( Transform  a,
Transform  b 
)
static
static int UIGrid.SortVertical ( Transform  a,
Transform  b 
)
static
virtual void UIGrid.Start ( )
protectedvirtual

Cache everything and reset the initial position of all children.

virtual void UIGrid.Update ( )
protectedvirtual

Reset the position if necessary, then disable the component.

Member Data Documentation

bool UIGrid.animateSmoothly = false

Whether the grid will smoothly animate its children into the correct place.

Arrangement UIGrid.arrangement = Arrangement.Horizontal

Type of arrangement – vertical or horizontal.

float UIGrid.cellHeight = 200f

The height of each of the cells.

float UIGrid.cellWidth = 200f

The width of each of the cells.

bool UIGrid.hideInactive = true

Whether to ignore the disabled children or to treat them as being present.

bool UIGrid.keepWithinPanel = false

Whether the parent container will be notified of the grid's changes.

int UIGrid.maxPerLine = 0

Maximum children per line. If the arrangement is horizontal, this denotes the number of columns. If the arrangement is vertical, this stands for the number of rows.

bool UIGrid.mInitDone = false
protected
UIPanel UIGrid.mPanel
protected
bool UIGrid.mReposition = false
protected
System.Comparison<Transform> UIGrid.onCustomSort

Custom sort delegate, used when the sorting method is set to 'custom'.

OnReposition UIGrid.onReposition

Callback triggered when the grid repositions its contents.

UIWidget.Pivot UIGrid.pivot = UIWidget.Pivot.TopLeft

Final pivot point for the grid's content.

Sorting UIGrid.sorting = Sorting.None

How to sort the grid's elements.

Property Documentation

bool UIGrid.repositionNow
set

Reposition the children on the next Update().


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