Namespace: | Sirenix.OdinInspector.Editor |
Assembly: | Sirenix.OdinInspector.Editor |
public sealed class PropertyContextContainer
Contains a context for an InspectorProperty, which offers the ability to address persistent values by key across several editor GUI frames.
Use this in drawers to store contextual editor-only values such as the state of a foldout.
public PropertyContextContainer(InspectorProperty property)
InspectorProperty | property | The property. |
System.ArgumentNullException | property |
Gets a global context value for a given key, and creates a new instance of
Global contexts are not associated with any one specific drawer, and so are shared across all drawers for this property.
public PropertyContext<T> GetGlobal<T>(string key)
where T : new()
System.String | key | The key of the context value to get. |
PropertyContext<T> | The found context. |
T | The type of the context value to get. |
Gets a global context value for a given key, using a given default value if the context doesn't already exist.
Global contexts are not associated with any one specific drawer, and so are shared across all drawers for this property.
public PropertyContext<T> GetGlobal<T>(string key, T defaultValue)
System.String | key | The key of the context value to get. |
T | defaultValue | The default value to set if the context value doesn't exist yet. |
PropertyContext<T> | The found context. |
T | The type of the context value to get. |
Gets a global context value for a given key, using a given delegate to generate a default value if the context doesn't already exist.
Global contexts are not associated with any one specific drawer, and so are shared across all drawers for this property.
public PropertyContext<T> GetGlobal<T>(string key, Func<T> getDefaultValue)
System.String | key | The key of the context value to get. |
System.Func<T> | getDefaultValue | A delegate for generating a default value. |
PropertyContext<T> | The found context. |
T | The type of the context value to get. |
public LocalPersistentContext<TValue> GetPersistent<TValue>(OdinDrawer drawer, string key, TValue defaultValue)
OdinDrawer | drawer | The instance of the drawer. |
System.String | key | The key for the context. |
TValue | defaultValue | The default value for the context. |
LocalPersistentContext<TValue> |
TValue | The type of the value of the context. |
true
when the GlobalPersistentContext<T> is first created. Otherwise false
.
public bool GetPersistent<TValue>(OdinDrawer drawer, string key, out LocalPersistentContext<TValue> context)
OdinDrawer | drawer | The instance of the drawer. |
System.String | key | The key for the context. |
LocalPersistentContext<TValue> | context | The LocalPersistentContext<T> object. |
System.Boolean | Returns |
TValue | The type of the value of the context. |
public void SwapContext(PropertyContextContainer otherContext)
PropertyContextContainer | otherContext | The context to swap with. |