Version 3.0.1.0

PropertyState class

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.OdinInspector.Editor
public sealed class PropertyState

This is a class for creating, getting and modifying a property's various states. An instance of this class always comes attached to an InspectorProperty.

See Odin's tutorials for more information about usage of the state system.

Inheritance
  • System.Object
  • PropertyState

Constructors

PropertyState(InspectorProperty, Int32)
public PropertyState(InspectorProperty property, int index)
Parameters
InspectorProperty property

System.Int32 index

Fields

LogChanges
If set to true, all state changes for this property will be logged to the console.
public bool LogChanges

Properties

Enabled
Whether the property is enabled in the inspector.
public bool Enabled { get; set; }
EnabledLastLayout
Whether the Enabled state was true or not during the last layout event.
public bool EnabledLastLayout { get; }
Expanded
Whether the property is expanded in the inspector.
public bool Expanded { get; set; }
ExpandedLastLayout
Whether the Expanded state was true or not during the last layout event.
public bool ExpandedLastLayout { get; }
Visible
Whether the property is visible in the inspector.
public bool Visible { get; set; }
VisibleLastLayout
Whether the Visible state was true or not during the last layout event.
public bool VisibleLastLayout { get; }

Methods

CleanForCachedReuse()
Cleans the property state and prepares it for cached reuse of its containing PropertyTree. This will also reset the state.
public void CleanForCachedReuse()
Create<T>(String, Boolean, T)
Creates a custom state with a given name.
public void Create<T>(string key, bool persistent, T defaultValue)
Parameters
System.String key

System.Boolean persistent

T defaultValue

Type Parameters
T

Exists(String)
Determines whether a state with the given key exists.
public bool Exists(string key)
Parameters
System.String key

The key to check.

Returns
System.Boolean

True if the state exists, otherwise, false.

Exists(String, out Boolean)
Determines whether a state with the given key exists.
public bool Exists(string key, out bool isPersistent)
Parameters
System.String key

The key to check.

System.Boolean isPersistent

If the state exists, this out parameter will be true if the state is persistent.

Returns
System.Boolean

True if the state exists, otherwise, false.

Exists(String, out Boolean, out Type)
Determines whether a state with the given key exists.
public bool Exists(string key, out bool isPersistent, out Type valueType)
Parameters
System.String key

The key to check.

System.Boolean isPersistent

If the state exists, this out parameter will be true if the state is persistent.

System.Type valueType

If the state exists, this out parameter will contain the type of value that the state contains.

Returns
System.Boolean

True if the state exists, otherwise, false.

Exists(String, out Type)
Determines whether a state with the given key exists.
public bool Exists(string key, out Type valueType)
Parameters
System.String key

The key to check.

System.Type valueType

If the state exists, this out parameter will contain the type of value that the state contains.

Returns
System.Boolean

True if the state exists, otherwise, false.

Get<T>(String)
Gets the value of a given state as an instance of type T.
public T Get<T>(string key)
Parameters
System.String key

The key of the state to get. An System.InvalidOperationException will be thrown if a state with the given key does not exist.

Returns
T

The value of the state.

Type Parameters
T

The type to get the state value as. An System.InvalidOperationException will be thrown if the state's value type cannot be assigned to T.

GetLastLayout<T>(String)
Gets the value that a given state contained last layout as an instance of type T.
public T GetLastLayout<T>(string key)
Parameters
System.String key

The key of the state to get. An System.InvalidOperationException will be thrown if a state with the given key does not exist.

Returns
T

The value of the state during the last layout event.

Type Parameters
T

The type to get the state value as. An System.InvalidOperationException will be thrown if the state's value type cannot be assigned to T.

Reset()
Resets all states to their default values. Persistent states will be updated to their persistent cached value if one exists.
public void Reset()
Set<T>(String, T)
Sets the value of a given state to a given value.
public void Set<T>(string key, T value)
Parameters
System.String key

The key of the state to set the value of. An System.InvalidOperationException will be thrown if a state with the given key does not exist.

T value

The value to set.

Type Parameters
T

The type to set the state value as. An System.InvalidOperationException will be thrown if T cannot be assigned to the state's value type.