UIStateGroupControl
CJFinc.​UItools.​UIStateGroup
public
CJFinc.​UItools.​UIStateGroupControl

UIStateGroupControl extends UIStateGroup into the group of items with only one item selected.

UIStateGroupControl-editor

UIStateGroupControl works with active and inactive states of UIStateItem.  It reacts to any UIStateItem state change and controls that only one item should be selected at the same time.

UIStateGroupControl-editor-hierarchy

There are two modes available - one active - one inactive

In "one active" UIStateGroupControl controls that only one item is active.

And "one inactive" has an inverse behavior when only one item could be inactive.

Types
STATE_GROUP_CONTROL_MODE
public enum STATE_GROUP_CONTROL_MODE

Enumeration of possible group modes

Properties
Mode
public STATE_GROUP_CONTROL_MODE Mode { get }

Current group mode STATE_GROUP_CONTROL_MODE

SelectedItem
public UIStateItem SelectedItem { get }

Currently selected UIStateItem item

SelectedItemName
public string SelectedItemName { get }

Currently selected UIStateItem item name

Functions
SetMode (newMode)
public void SetMode(
STATE_GROUP_CONTROL_MODE newMode
)

Change group mode and set items to initial states

GetComponent<UIStateGroupControl>().SetMode(STATE_GROUP_CONTROL_MODE.OneInActive);
Parameters
newMode

STATE_GROUP_CONTROL_MODE new group mode

ItemStateChanged (itemName)
public override void ItemStateChanged(
string itemName
)

Internal function. Called automatically from UIStateItem for each state change

See UIStateGroup.ItemStateChanged (itemName) for details.

Parameters
itemName
string

item name

SetItemActive(itemName)
public void SetItemActive(
string itemName
)

Change item with given name to state UIStateItem.STATE_ACTIVE

GetComponent<UIStateGroupControl>().SetItemActive("item (2)");
Parameters
itemName
string

UIStateItem item name

SetItemInactive(itemName)
public void SetItemInactive(
string itemName
)

Change item with given name to state UIStateItem.STATE_INACTIVE

GetComponent<UIStateGroupControl>().SetItemInactive("item (2)");
Parameters
itemName
string

UIStateItem item name

SelectFirstItem()
public void SelectFirstItem()

Flushes state for all items and makes active the first one

// Example - selecting first item in group init
// NOTE: Make sure to disable Init on start for all items, to let group control init state

void Awake() {
GetComponent<UIStateGroupControl>().OnInitFinish.AddListener(OnRadioGroupInitFinished);
}

void OnRadioGroupInitFinished() {
GetComponent<UIStateGroupControl>().SelectFirstItem();
}
Flush()
public void Flush()

Flush all items for default state according to current Mode

GetComponent<UIStateGroupControl>().Flush();