> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksinspectorstatemap-2.md).

# Class ksInspectorStateMap\<State, Self>

Namespace: [KS.Unity.Editor](/reactor/api-reference/ks.unity.editor.md)\
Assembly: KSUnity-Editor.dll

This can be used by property drawers and custom inspectors to store per-property custom state that persists through Unity serializations. The state is not saved to disk so it only persists as long as Unity is open. A property is indentified by its name and the name of the script is belongs to.

This class inherits from [ksSingleton%601](/reactor/api-reference/ks.unity.editor.md#KS_Unity_Editor_ksSingleton_601), so it should be accessed using the singleton accessor [Get](/reactor/api-reference/ks.unity.editor.md#KS_Unity_Editor_ksSingleton_601_Get).

```csharp
public class ksInspectorStateMap<State, Self> : ksSingleton<Self> where Self : ScriptableObject
```

#### Type Parameters

`State`

State type to store with the property.

`Self`

The singleton type. Should be the type that inherits from class.

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† Object â† ScriptableObject â† [ksSingleton\<Self>](/reactor/api-reference/ks.unity.editor/ks.unity.editor.kssingleton-1.md) â† [ksInspectorStateMap\<State, Self>](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksinspectorstatemap-2.md)

#### Inherited Members

[ksSingleton\<Self>.Get()](/reactor/api-reference/ks.unity.editor/ks.unity.editor.kssingleton-1.md#KS_Unity_Editor_ksSingleton_1_Get), [ksSingleton\<Self>.Initialize()](/reactor/api-reference/ks.unity.editor/ks.unity.editor.kssingleton-1.md#KS_Unity_Editor_ksSingleton_1_Initialize), [ksSingleton\<Self>.Create()](/reactor/api-reference/ks.unity.editor/ks.unity.editor.kssingleton-1.md#KS_Unity_Editor_ksSingleton_1_Create), ScriptableObject.SetDirty(), ScriptableObject.CreateInstance(string), ScriptableObject.CreateInstance(Type), ScriptableObject.CreateInstance\<T>(), Object.GetInstanceID(), Object.GetHashCode(), Object.Equals(object), Object.Instantiate(Object, Vector3, Quaternion), Object.Instantiate(Object, Vector3, Quaternion, Transform), Object.Instantiate(Object), Object.Instantiate(Object, Transform), Object.Instantiate(Object, Transform, bool), Object.Instantiate\<T>(T), Object.Instantiate\<T>(T, Vector3, Quaternion), Object.Instantiate\<T>(T, Vector3, Quaternion, Transform), Object.Instantiate\<T>(T, Transform), Object.Instantiate\<T>(T, Transform, bool), Object.Destroy(Object, float), Object.Destroy(Object), Object.DestroyImmediate(Object, bool), Object.DestroyImmediate(Object), Object.FindObjectsOfType(Type), Object.FindObjectsOfType(Type, bool), Object.FindObjectsByType(Type, FindObjectsSortMode), Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode), Object.DontDestroyOnLoad(Object), Object.DestroyObject(Object, float), Object.DestroyObject(Object), Object.FindSceneObjectsOfType(Type), Object.FindObjectsOfTypeIncludingAssets(Type), Object.FindObjectsOfType\<T>(), Object.FindObjectsByType\<T>(FindObjectsSortMode), Object.FindObjectsOfType\<T>(bool), Object.FindObjectsByType\<T>(FindObjectsInactive, FindObjectsSortMode), Object.FindObjectOfType\<T>(), Object.FindObjectOfType\<T>(bool), Object.FindFirstObjectByType\<T>(), Object.FindAnyObjectByType\<T>(), Object.FindFirstObjectByType\<T>(FindObjectsInactive), Object.FindAnyObjectByType\<T>(FindObjectsInactive), Object.FindObjectsOfTypeAll(Type), Object.FindObjectOfType(Type), Object.FindFirstObjectByType(Type), Object.FindAnyObjectByType(Type), Object.FindObjectOfType(Type, bool), Object.FindFirstObjectByType(Type, FindObjectsInactive), Object.FindAnyObjectByType(Type, FindObjectsInactive), Object.ToString(), Object.name, Object.hideFlags, [object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Properties

### DefaultState <a href="#ks_unity_editor_ksinspectorstatemap_2_defaultstate" id="ks_unity_editor_ksinspectorstatemap_2_defaultstate"></a>

The default state to return if there is no state in the map.

```csharp
public virtual State DefaultState { get; }
```

#### Property Value

State

## Methods

### Get(SerializedProperty) <a href="#ks_unity_editor_ksinspectorstatemap_2_get_unityeditor_serializedproperty" id="ks_unity_editor_ksinspectorstatemap_2_get_unityeditor_serializedproperty"></a>

Gets the state associated with a property.

```csharp
public State Get(SerializedProperty property)
```

#### Parameters

`property` SerializedProperty

Property to get state for.

#### Returns

State

The state for the property, or [DefaultState](/reactor/api-reference/ks.unity.editor.md#KS_Unity_Editor_ksInspectorStateMap_602_DefaultState) if there was no state for the property.

### Set(SerializedProperty, State) <a href="#ks_unity_editor_ksinspectorstatemap_2_set_unityeditor_serializedproperty__0" id="ks_unity_editor_ksinspectorstatemap_2_set_unityeditor_serializedproperty__0"></a>

Sets the state associated with a property.

```csharp
public void Set(SerializedProperty property, State state)
```

#### Parameters

`property` SerializedProperty

Property to set state for.

`state` State

State to set.
