Version 3.3.0.1

PropertyTree class

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.OdinInspector.Editor
public abstract class PropertyTree : IDisposable

Represents a set of values of the same type as a tree of properties that can be drawn in the inspector, and provides an array of utilities for querying the tree of properties.

Inheritance
  • System.Object
  • PropertyTree

Constructors

PropertyTree()
Creates a new PropertyTree for all target values of a UnityEditor.SerializedObject.
public PropertyTree()

Fields

AllowSearchFiltering
public bool AllowSearchFiltering
ComponentProviders
The component providers that create components for each property in the tree. If you change this list after the tree has been used, you should call tree.RootProperty.RefreshSetup() to make the changes update properly throughout the tree.
public readonly List<ComponentProvider> ComponentProviders
EnableLeakDetection
public static readonly EditorPrefBool EnableLeakDetection
monoScriptProperty
protected SerializedProperty monoScriptProperty
monoScriptPropertyHasBeenGotten
protected bool monoScriptPropertyHasBeenGotten
RecordUndoForChanges
public bool RecordUndoForChanges

Properties

AttributeProcessorLocator
Gets or sets the OdinAttributeProcessorLocator for the PropertyTree.
public OdinAttributeProcessorLocator AttributeProcessorLocator { get; set; }
DrawerChainResolver
Gets or sets the DrawerChainResolver for the PropertyTree.
public DrawerChainResolver DrawerChainResolver { get; set; }
DrawMonoScriptObjectField
Gets a value indicating whether or not to draw the mono script object field at the top of the property tree.
public bool DrawMonoScriptObjectField { get; set; }
HasRootPropertyYet
protected abstract bool HasRootPropertyYet { get; }
IsStatic
Gets a value indicating whether or not the PropertyTree is inspecting a static type.
public bool IsStatic { get; protected set; }
PrefabModificationHandler
The prefab modification handler of the tree.
public abstract PrefabModificationHandler PrefabModificationHandler { get; }
PropertyResolverLocator
Gets or sets the OdinPropertyResolverLocator for the PropertyTree.
public OdinPropertyResolverLocator PropertyResolverLocator { get; set; }
RootProperty
Gets the root property of the tree.
public abstract InspectorProperty RootProperty { get; }
RootPropertyCount
The number of root properties in the tree.
public abstract int RootPropertyCount { get; }
SerializationBackend
The serialization backend used to determine how to draw this property tree. Set this to control.
public SerializationBackend SerializationBackend { get; set; }
StateUpdaterLocator
Gets or sets the StateUpdaterLocator for the PropertyTree.
public StateUpdaterLocator StateUpdaterLocator { get; set; }
TargetType
The type of the values that the property tree represents.
public abstract Type TargetType { get; }
UnitySerializedObject
The UnityEditor.SerializedObject that this tree represents, if the tree was created for a UnityEditor.SerializedObject.
public abstract SerializedObject UnitySerializedObject { get; }
UpdateID
The current update ID of the tree. This is incremented once, each update, and is used by Update(Boolean) to avoid updating multiple times in the same update round.
public abstract int UpdateID { get; }
WeakTargets
The actual values that the property tree represents.
public abstract ImmutableList<object> WeakTargets { get; }

Methods

ApplyChanges()
Applies all changes made with properties to the inspected target tree values, and marks all changed Unity objects dirty.
public abstract bool ApplyChanges()
Returns
System.Boolean

true if any values were changed, otherwise false

BeginDraw(Boolean)
public void BeginDraw(bool withUndo)
Parameters
System.Boolean withUndo

CleanForCachedReuse()
public abstract void CleanForCachedReuse()
Create(IList)

Creates a new PropertyTree for a set of given target values.

Note that the targets all need to be of the same type.

public static PropertyTree Create(IList targets)
Parameters
System.Collections.IList targets

The targets to create a tree for.

Returns
PropertyTree

Create(IList, SerializationBackend)

Creates a new PropertyTree for a set of given target values.

Note that the targets all need to be of the same type.

public static PropertyTree Create(IList targets, SerializationBackend backend)
Parameters
System.Collections.IList targets

The targets to create a tree for.

SerializationBackend backend

The serialization backend to use for the tree root.

Returns
PropertyTree

Create(IList, SerializedObject)

Creates a new PropertyTree for a set of given target values, represented by a given UnityEditor.SerializedObject.

Note that the targets all need to be of the same type.

public static PropertyTree Create(IList targets, SerializedObject serializedObject)
Parameters
System.Collections.IList targets

The targets to create a tree for.

UnityEditor.SerializedObject serializedObject

The serialized object to create a tree for. Note that the target values of the given UnityEditor.SerializedObject must be the same values given in the targets parameter.

Returns
PropertyTree

Create(IList, SerializedObject, SerializationBackend)

Creates a new PropertyTree for a set of given target values, represented by a given UnityEditor.SerializedObject.

Note that the targets all need to be of the same type.

public static PropertyTree Create(IList targets, SerializedObject serializedObject, SerializationBackend backend)
Parameters
System.Collections.IList targets

The targets to create a tree for.

UnityEditor.SerializedObject serializedObject

The serialized object to create a tree for. Note that the target values of the given UnityEditor.SerializedObject must be the same values given in the targets parameter.

SerializationBackend backend

The serialization backend to use for the tree root.

Returns
PropertyTree

Create(Object)
Creates a new PropertyTree for a given target value.
public static PropertyTree Create(object target)
Parameters
System.Object target

The target to create a tree for.

Returns
PropertyTree

Exceptions
System.ArgumentNullException

target is null

Create(Object, SerializationBackend)
Creates a new PropertyTree for a given target value.
public static PropertyTree Create(object target, SerializationBackend backend)
Parameters
System.Object target

The target to create a tree for.

SerializationBackend backend

The serialization backend to use for the tree root.

Returns
PropertyTree

Exceptions
System.ArgumentNullException

target is null

Create(Object[])

Creates a new PropertyTree for a set of given target values.

Note that the targets all need to be of the same type.

public static PropertyTree Create(params object[] targets)
Parameters
System.Object[] targets

The targets to create a tree for.

Returns
PropertyTree

Exceptions
System.ArgumentNullException

targets is null

Create(SerializedObject)
Creates a new PropertyTree for all target values of a UnityEditor.SerializedObject.
public static PropertyTree Create(SerializedObject serializedObject)
Parameters
UnityEditor.SerializedObject serializedObject

The serialized object to create a tree for.

Returns
PropertyTree

Exceptions
System.ArgumentNullException

serializedObject is null

Create(SerializedObject, SerializationBackend)
Creates a new PropertyTree for all target values of a UnityEditor.SerializedObject.
public static PropertyTree Create(SerializedObject serializedObject, SerializationBackend backend)
Parameters
UnityEditor.SerializedObject serializedObject

The serialized object to create a tree for.

SerializationBackend backend

The serialization backend to use for the tree root.

Returns
PropertyTree

Exceptions
System.ArgumentNullException

serializedObject is null

CreateStatic(Type)
Creates a PropertyTree to inspect the static values of the given type.
public static PropertyTree CreateStatic(Type type)
Parameters
System.Type type

The type to inspect.

Returns
PropertyTree

A PropertyTree instance for inspecting the type.

DelayAction(Action)
Schedules a delegate to be invoked at the end of the current GUI frame.
public abstract void DelayAction(Action action)
Parameters
System.Action action

The action delegate to be delayed.

DelayActionUntilRepaint(Action)
Schedules a delegate to be invoked at the end of the next Repaint GUI frame.
public abstract void DelayActionUntilRepaint(Action action)
Parameters
System.Action action

The action to be delayed.

Dispose()
public void Dispose()
Dispose(Boolean)
protected virtual void Dispose(bool finalizer)
Parameters
System.Boolean finalizer

DisposeAndResetRootProperty()
protected abstract void DisposeAndResetRootProperty()
DisposeInheritedStuff()
protected abstract void DisposeInheritedStuff()
Draw(Boolean)

Draw the property tree, and handles management of undo, as well as marking scenes and drawn assets dirty.

This is a shorthand for calling Sirenix.OdinInspector.Editor.InspectorUtilities.BeginDrawPropertyTree(Sirenix.OdinInspector.Editor.PropertyTree,System.Boolean), DrawPropertiesInTree(PropertyTree) and . Sirenix.OdinInspector.Editor.InspectorUtilities.EndDrawPropertyTree(Sirenix.OdinInspector.Editor.PropertyTree).

public void Draw(bool applyUndo = true)
Parameters
System.Boolean applyUndo

DrawProperties()
public void DrawProperties()
DrawSearch()

Draws a search bar for the property tree, and draws the search results if the search bar is used.

If this method returns true, the property tree should generally not be drawn normally afterwards.

Note that this method will throw exceptions if the property tree is not set up to be searchable; for that, see SetSearchable(Boolean, SearchableAttribute).

public bool DrawSearch()
Returns
System.Boolean

True if the property tree is being searched and is currently drawing its search results, otherwise false.

EndDraw()
public void EndDraw()
EnumerateTree(Boolean, Boolean)
Enumerates over the properties of the tree.
public abstract IEnumerable<InspectorProperty> EnumerateTree(bool includeChildren = true, bool onlyVisible = false)
Parameters
System.Boolean includeChildren

Whether to include children of the root properties or not. If set to true, every property in the entire tree will be enumerated.

System.Boolean onlyVisible

Whether to only include visible properties. Properties whose parents are invisible are considered invisible.

Returns
System.Collections.Generic.IEnumerable<InspectorProperty>

Finalize()
protected void Finalize()
GetPropertyAtPath(String)
Gets the property at the given path. Note that this is the path found in Path, not the Unity path.
public abstract InspectorProperty GetPropertyAtPath(string path)
Parameters
System.String path

The path of the property to get.

GetPropertyAtPath(String, out InspectorProperty)
Gets the property at the given path. Note that this is the path found in Path, not the Unity path.
public abstract InspectorProperty GetPropertyAtPath(string path, out InspectorProperty closestProperty)
Parameters
System.String path

The path of the property to get.

InspectorProperty closestProperty

GetPropertyAtPrefabModificationPath(String)
Gets the property at the given Odin prefab modification path.
public abstract InspectorProperty GetPropertyAtPrefabModificationPath(string path)
Parameters
System.String path

The prefab modification path of the property to get.

GetPropertyAtPrefabModificationPath(String, out InspectorProperty)
Gets the property at the given Odin prefab modification path.
public abstract InspectorProperty GetPropertyAtPrefabModificationPath(string path, out InspectorProperty closestProperty)
Parameters
System.String path

The prefab modification path of the property to get.

InspectorProperty closestProperty

GetPropertyAtUnityPath(String)
Gets the property at the given Unity path.
public abstract InspectorProperty GetPropertyAtUnityPath(string path)
Parameters
System.String path

The Unity path of the property to get.

GetPropertyAtUnityPath(String, out InspectorProperty)
Gets the property at the given Unity path.
public abstract InspectorProperty GetPropertyAtUnityPath(string path, out InspectorProperty closestProperty)
Parameters
System.String path

The Unity path of the property to get.

InspectorProperty closestProperty

GetReferenceCount(Object)
Gets the number of references to a given object instance in this tree.
public abstract int GetReferenceCount(object reference)
Parameters
System.Object reference

Returns
System.Int32

GetRootProperty(Int32)
Gets the root tree property at a given index.
public abstract InspectorProperty GetRootProperty(int index)
Parameters
System.Int32 index

The index of the property to get.

GetUnityPropertyForPath(String)
Gets a Unity property for the given Odin or Unity path. If there is no UnityEditor.SerializedObject for this property tree, or no such property is found in the UnityEditor.SerializedObject, a property will be emitted using UnityPropertyEmitter.
public SerializedProperty GetUnityPropertyForPath(string path)
Parameters
System.String path

The Odin or Unity path to the property to get.

Returns
UnityEditor.SerializedProperty

GetUnityPropertyForPath(String, out FieldInfo)
Gets a Unity property for the given Odin or Unity path. If there is no UnityEditor.SerializedObject for this property tree, or no such property is found in the UnityEditor.SerializedObject, a property will be emitted using UnityPropertyEmitter.
public abstract SerializedProperty GetUnityPropertyForPath(string path, out FieldInfo backingField)
Parameters
System.String path

The Odin or Unity path to the property to get.

System.Reflection.FieldInfo backingField

The backing field of the Unity property.

Returns
UnityEditor.SerializedProperty

InitSearchFilter()
protected void InitSearchFilter()
InvokeDelayedActions()
Invokes the actions that have been delayed using DelayAction(Action) and DelayActionUntilRepaint(Action).
public abstract void InvokeDelayedActions()
InvokeOnValidate()
Invokes the OnValidate method on the property tree's targets if they are derived from UnityEngine.Object and have the method defined.
public void InvokeOnValidate()
ObjectIsReferenced(Object, out String)
Checks whether a given object instance is referenced anywhere in the tree, and if it is, gives the path of the first time the object reference was encountered as an out parameter.
public abstract bool ObjectIsReferenced(object value, out string referencePath)
Parameters
System.Object value

The reference value to check.

System.String referencePath

The first found path of the object.

Returns
System.Boolean

RegisterPropertyDirty(InspectorProperty)
Registers that a given property is dirty and needs its changes to be applied at the end of the current frame.
public abstract void RegisterPropertyDirty(InspectorProperty property)
Parameters
InspectorProperty property

ReplaceAllReferences(Object, Object)
Replaces all occurrences of a value with another value, in the entire tree.
public abstract void ReplaceAllReferences(object from, object to)
Parameters
System.Object from

The value to find all instances of.

System.Object to

The value to replace the found values with.

SetSearchable(Boolean, SearchableAttribute)

Sets whether the property tree should be searchable or not, and allows the passing in of a custom SearchableAttribute instance to configure the search.

public void SetSearchable(bool searchable, SearchableAttribute config = null)
Parameters
System.Boolean searchable

Whether the tree should be set to be searchable or not.

SearchableAttribute config

If the tree is set to be searchable, then if this parameter is not null, it will be used to configure the property tree search. If the parameter is null, the SearchableAttribute on the tree's RootProperty will be used. If that property has no such attribute, then default search settings will be applied.

SetSerializedObject(SerializedObject)
public abstract void SetSerializedObject(SerializedObject serializedObject)
Parameters
UnityEditor.SerializedObject serializedObject

SetTargets(Object[])
public abstract void SetTargets(params object[] newTargets)
Parameters
System.Object[] newTargets

SetUpForIMGUIDrawing()
public PropertyTree SetUpForIMGUIDrawing()
Returns
PropertyTree

SetUpForValidation()
public PropertyTree SetUpForValidation()
Returns
PropertyTree

UpdateTree()
Updates all properties in the entire tree, and validates the prefab state of the tree, if applicable.
public abstract void UpdateTree()

Events

OnPropertyValueChanged
This event is invoked whenever the value of any property in the entire property tree is changed through the property system.
public event PropertyTree.OnPropertyValueChangedDelegate OnPropertyValueChanged
OnUndoRedoPerformed
An event that is invoked whenever an undo or a redo is performed in the inspector. The advantage of using this event on a property tree instance instead of UnityEditor.Undo.undoRedoPerformed is that this event will be desubscribed from UnityEditor.Undo.undoRedoPerformed when the selection changes and the property tree is no longer being used, allowing the GC to collect the property tree.
public event Action OnUndoRedoPerformed
Derived Classes