Overview

States are an XML UI frame type that enables you to set up state groups on UI frames. Similar to Constants, States are a “meta” frame that doesn’t create an actual UI object. They’re just for storing information.

Use Cases

There are a variety of uses for state groups:

Making adjustments to UI if the device is iPhone vs Android

In some cases, UI needs to be adjusted to account for different margins or cameras on different devices.

2023-03-24 12-02-09.mp4

Changing UI to reflect if an element is for the player or the enemy

Often the enemy will have the same UI as the player, only mirrored or changed to red instead of the player’s color of green or blue. Instead of building separate UI for the player and for the enemy, the same UI can be used with a state to modify the appearance.

2023-03-28 14-55-30.mp4

Reflecting if the UI element is selected/highlighted

Selected items often have a glow outline, which can be easily toggled on/off with state groups.

2023-03-28 14-57-07.mp4

Toggling items between Equipped/Uequipped or Locked/Unlocked

Equipable items or unlockable gears states of ownership or usage is a common use case for state groups. Typically this involves toggling a “black mask” and a lock icon.