The SetProperty method can be used to assign any property on a GraphicalUiElement by the name of the property. This method is used internally to apply states, but it can also be used to perform scripting or assign state values without access to code generated types.
The following code assigns the Y value of a ColoredRectangle according to keyboard input.
SetProperty allows the assignment of states by state name. This is useful when writing code which should apply to any type of Gum object as long as it contains the required category and states. This example assumes a component with a Size category containing two states: Big and Small.
This will automatically generate an enumeration and property in the component:
If you are writing code where you do not have access to the specific types, the state category can still be assigned using SetProperty as shown in the following code. Notice that the variable name does not use the prefix "Current", so the variable assigned is simply "SizeState":