Version 2.1.0.0

PropertyTree<T> class

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.OdinInspector.Editor
public sealed class PropertyTree<T> : PropertyTree, IDisposable

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

This class also handles management of prefab modifications.

Inheritance

Type Parameters

T

Constructors

PropertyTree()
Initializes a new instance of the PropertyTree<T> class, inspecting only the target () type's static members.
public PropertyTree()
PropertyTree(T[])
Initializes a new instance of the PropertyTree<T> class.
public PropertyTree(T[] targets)
Parameters
T[] targets

The targets to represent.

PropertyTree(T[], SerializedObject)
Initializes a new instance of the PropertyTree<T> class.
public PropertyTree(T[] targets, SerializedObject serializedObject)
Parameters
T[] targets

The targets to represent.

UnityEditor.SerializedObject serializedObject

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

Exceptions
System.ArgumentNullException

targets is null

System.ArgumentException

There must be at least one target. or A given target is a null value.

PropertyTree(SerializedObject)
Initializes a new instance of the PropertyTree<T> class.
public PropertyTree(SerializedObject serializedObject)
Parameters
UnityEditor.SerializedObject serializedObject

The serialized object to represent.

Properties

PrefabModificationHandler
Gets the Sirenix.OdinInspector.Editor.PropertyTree`1.prefabModificationHandler for the PropertyTree.
public override PrefabModificationHandler PrefabModificationHandler { get; }
RootPropertyCount
The number of root properties in the tree.
public override int RootPropertyCount { get; }
SecretRootProperty
Gets the secret root property of the PropertyTree.
public override InspectorProperty SecretRootProperty { get; }
Targets
The strongly types actual values that the property tree represents.
public ImmutableList<T> Targets { get; }
TargetType
The type of the values that the property tree represents.
public override Type TargetType { get; }
UnitySerializedObject
The UnityEditor.SerializedObject that this tree represents, if the tree was created for a UnityEditor.SerializedObject.
public override 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 override int UpdateID { get; }
WeakTargets
The weakly types actual values that the property tree represents.
public override ImmutableList<object> WeakTargets { get; }

Methods

ApplyChanges()
Applies all changes made with properties to the inspected target tree values.
public override bool ApplyChanges()
Returns
System.Boolean

true if any values were changed, otherwise false

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

The action delegate to be delayed.

Exceptions
System.ArgumentNullException

action

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

The action to be delayed.

Exceptions
System.ArgumentNullException

action

EnumerateTree(Boolean)
Enumerates over the properties of the tree. WARNING: For tree that have large targets with lots of data, this may involve massive amounts of work as the full tree structure is resolved. USE THIS METHOD SPARINGLY AND ONLY WHEN ABSOLUTELY NECESSARY!
public override IEnumerable<InspectorProperty> EnumerateTree(bool includeChildren)
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.

Returns
System.Collections.Generic.IEnumerable<InspectorProperty>

GetPropertyAtPath(String)
Gets the property at the given path. Note that this is the path found in Path, not the Unity path.
public override 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 override InspectorProperty GetPropertyAtPath(string path, out InspectorProperty closestProperty)
Parameters
System.String path

The path of the property to get.

InspectorProperty closestProperty

GetPropertyAtPrefabModificationPath(String)
Finds the property at the specified modification path.
public override InspectorProperty GetPropertyAtPrefabModificationPath(string path)
Parameters
System.String path

The prefab modification path for the property.

Returns
InspectorProperty

The property found at the path.

GetPropertyAtPrefabModificationPath(String, out InspectorProperty)
Finds the property at the specified modification path.
public override InspectorProperty GetPropertyAtPrefabModificationPath(string path, out InspectorProperty closestProperty)
Parameters
System.String path

The prefab modification path for the property.

InspectorProperty closestProperty

Returns
InspectorProperty

The property found at the path.

GetPropertyAtUnityPath(String)
Finds the property at the specified unity path.
public override InspectorProperty GetPropertyAtUnityPath(string path)
Parameters
System.String path

The unity path for the property.

Returns
InspectorProperty

The property found at the path.

GetPropertyAtUnityPath(String, out InspectorProperty)
Finds the property at the specified unity path.
public override InspectorProperty GetPropertyAtUnityPath(string path, out InspectorProperty closestProperty)
Parameters
System.String path

The unity path for the property.

InspectorProperty closestProperty

Returns
InspectorProperty

The property found at the path.

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

Returns
System.Int32

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

The index of the property to get.

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 override 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

InvokeDelayedActions()
Invokes the actions that have been delayed using DelayAction(Action) and DelayActionUntilRepaint(Action).
public override void InvokeDelayedActions()
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 override 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 override void RegisterPropertyDirty(InspectorProperty property)
Parameters
InspectorProperty property

Exceptions
System.NotImplementedException

ReplaceAllReferences(Object, Object)
Replaces all occurrences of a value with another value, in the entire tree.
public override 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.

Exceptions
System.ArgumentNullException

System.ArgumentException

The value to replace with must either be null or be the same type as the value to replace (" + from.GetType().Name + ").

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