Polis.Core.StateHandling (Packages/PolisCore/StateHandling)AStateValuePresetWhen you only need two states: On/Off, Enabled/Disabled, Visible/Hidden
A state is a bool
All types inherit from AToggleState (Polis.Core.StateHandling.ToggleStates)
SetState(bool state, bool immediate = false) sets the state. The State property does the same
immediate only matters for animated implementations (TweenToggleState), instant ones ignore itevent Action<bool, bool> StateChanged - (state, immediate), invoked after every SetStateRefreshState() re-applies the current state. RefreshVisuals() re-applies it immediately, called when the UI style changesToggleState
ToggleStateObjects in the context menu / Convert to Objects
ToggleStateObjects
ToggleState in the context menu / Convert to Presets
TweenToggleState
When there can be more than 2 states, e.g. Unloaded/Loading/Loaded or A/B/C/D
A state is a string ID
All types inherit from AMultiState (Polis.Core.StateHandling.MultiStates)
bool SetState(string state, bool immediate = false) sets the state
bool SetState(Enum stateID, bool immediate = false) uses the enum value name as the IDHasState(string), GetAllStates(), State, DefaultStateAToggleStateMultiState
MultiStateObjects in the context menu / Convert to Objects
MultiStateObjects
MultiState in the context menu / Convert to Presets
Enum states: put [ValidateMultiState(typeof(MyEnum))] on an AMultiState field. Odin validation shows missing or extra states and offers a fix that adds or removes them. Then call SetState(MyEnum.Value). See NetworkStateDisplay