Version 3.3.0.1

Odin has a dedicated attribute overview with examples

OnStateUpdateAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[DontApplyToListElements]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = true, Inherited = true)]
[Conditional("UNITY_EDITOR")]
[IncludeMyAttributes]
[HideInTables]
public sealed class OnStateUpdateAttribute : Attribute, _Attribute

OnStateUpdate provides an event callback when the property's state should be updated, when the StateUpdaters run on the property instance. This generally happens at least once per frame, and the callback will be invoked even when the property is not visible. This can be used to approximate custom StateUpdaters like [ShowIf] without needing to make entire attributes and StateUpdaters for one-off cases.

Inheritance
  • System.Object
  • System.Attribute
  • OnStateUpdateAttribute
Example

The following example shows how OnStateUpdate can be used to control the visible state of a property.

public class MyComponent : MonoBehaviour
{
	[OnStateUpdate("@$property.State.Visible = ToggleMyInt")]
	public int MyInt;

	public bool ToggleMyInt;
}
Example

The following example shows how OnStateUpdate can be used to control the expanded state of a list.

public class MyComponent : MonoBehaviour
{
	[OnStateUpdate("@$property.State.Expanded = ExpandList")]
	public List<string> list;

	public bool ExpandList;
}

The following example shows how OnStateUpdate can be used to control the state of another property.

public class MyComponent : MonoBehaviour
{
	public List>string< list;

	[OnStateUpdate("@#(list).State.Expanded = $value")]
	public bool ExpandList;
}

Constructors

OnStateUpdateAttribute(String)
public OnStateUpdateAttribute(string action)
Parameters
System.String action

Fields

Action
public string Action