State categories automatically create variables in Screens and Entities through generated code. These generated variables can also be accessed in the FRB editor so they can be set on instances, or to assign change events.
For this example, consider an Entity named StateEntity which has a SizeCategory with three states: Small, Medium, and Large.
This entity generates a variable called CurrentSizeCategoryState which can be accessed in code, as shown in the following code block:
The CurrentSizeCategoryState can be tunneled on the entity which can be useful in a number of situations:
To set a default state for the entity
To set the state per-instance in the FRB Editor
To create events which is raised whenever a state is set to perform custom logic
To tunnel into a variable, drag+drop the category on the Variables folder.
The tunneled variable now behaves like any other variable. For example, an event can be added to the variable which is raised whenever the SizeCategory changes.