UIGroup
CJFinc.​RichMonoBehaviour
public
CJFinc.​UItools.​UIGroup
CJFinc.​UItools.​UIStateGroup

UIGroup component allows you to create a group of items and get access to any item by name or id.

UIGroup group = GetComponent<UIGroup>();

// get by id
UIItem firstItem = group.GetItem(0);

// get by name
UIItem itemByName = group.GetItem("item (2)");

There is a two items detection modes available - Automatic (default) - Manual

UIGroup-editor

In "Automatic" mode UIGroup detects items from its children.

NOTE: Disabled game objects and game objects with disabled UIItem component are ignores.

UIGroup-editor-and-hierarchy-items-automatic

"Manual" mode allows to define items for group from anywhere in hierarchy.

UIGroup-editor-and-hierarchy-items-manual
Details

For each group item the UIItem.group parameter will be linked to current group.

UIGroup-editor-and-hierarchy-items-group

You may need to force re-init group when items count has been changed in runtime in hierarchy (item added/removed, enabled/disabled)

UIGroup group = GetComponent<UIGroup>();
group.InitForce();

Supported items classes are UIItem and all it descendant.

Variables
items
public UIItem [] items

Array of UIItem items assigned to current group

Debug.Log("UIGroup items count = " + GetComponent<UIGroup>().items.Length);
Functions
GetItem (id)
public UIItem GetItem(
int id
)

Find item by id in items array

UIItem item = GetComponent<UIGroup>().GetItem(0);
Parameters
id
int

item id from items array

Returns

Found UIItem or null

GetItem (name)
public UIItem GetItem(
string name
)

Find item by name in items array

UIItem item = GetComponent<UIGroup>().GetItem("item 1");
Parameters
name
string

item name

Returns

Found UIItem or null