ApplyState can be used to apply a state (StateSave) to a GraphicalUiElement. States can be set by direct StateSave reference, or by unqualified name. Direct StateSave assignment supports states defined in Gum or dynamically created states.
Code Example - Setting States by Reference
Code Example - Setting States by Name
Code Example - Creating Dynamic States
var stateToSet =setMeInCode.ElementSave.Categories .FirstOrDefault(item =>item.Name=="RightSideCategory") .States.Find(item =>item.Name=="Blue");setMeInCode.ApplyState(stateToSet);
setMeInCode.ApplyState("Green");
var dynamicState =newStateSave();dynamicState.Variables.Add(newVariableSave(){ Value =300f, Name ="Width", Type ="float", // values can exist on a state but be "disabled" SetsValue =true});dynamicState.Variables.Add(newVariableSave(){ Value =250f, Name ="Height", Type ="float", SetsValue =true});setMeInCode.ApplyState(dynamicState);