Version 3.3.1.2

PrefabModificationHandler class

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.OdinInspector.Editor
public sealed class PrefabModificationHandler : IDisposable

Handles all prefab modifications that apply to the targets of a property tree, if any. This class determines which properties have modifications, what the modifications are, auto-applies modifications if the current instance values do not correspond to the prefab values, and also provides an API for modifying those modifications.

NOTE: This class is liable to see a lot of changes, as the prefab modification system is slated to be redesigned for increased extendability in the future. Do not depend overly on the current API.

Inheritance
  • System.Object
  • PrefabModificationHandler

Constructors

PrefabModificationHandler(PropertyTree)
public PrefabModificationHandler(PropertyTree tree)
Parameters
PropertyTree tree

Properties

HasNestedOdinPrefabData
public bool HasNestedOdinPrefabData { get; }
HasPrefabs
Whether any of the values the property tree represents are prefab instances.
public bool HasPrefabs { get; }
PrefabPropertyTree
A prefab tree for the prefabs of this property tree's prefab instances, if any exist.
public PropertyTree PrefabPropertyTree { get; }
TargetPrefabs
The prefabs for each prefab instance represented by the property tree, if any.
public ImmutableList<Object> TargetPrefabs { get; }
Tree
public PropertyTree Tree { get; }

Methods

CleanForCachedReuse()
public void CleanForCachedReuse()
Dispose()
public void Dispose()
GetPrefabModifications(Int32)
Gets all prefab modifications in this property tree for a given selection index.
public List<PrefabModification> GetPrefabModifications(int targetIndex)
Parameters
System.Int32 targetIndex

Returns
System.Collections.Generic.List<PrefabModification>

GetPrefabModificationType(InspectorProperty, Boolean)
Gets the Odin prefab modification type of a given property, if any.
public PrefabModificationType? GetPrefabModificationType(InspectorProperty property, bool forceAutoRegister = false)
Parameters
InspectorProperty property

The property to check.

System.Boolean forceAutoRegister

Returns
System.Nullable<PrefabModificationType>

The prefab modification type of the property if it has one, otherwise null.

GetUnityPropertyModification(StringSlice, Int32, out Boolean)
Gets the Unity PropertyModification for the property at this path, if there are any.
public PropertyModification GetUnityPropertyModification(StringSlice path, int selectionIndex, out bool childrenHaveModifications)
Parameters
StringSlice path

The property path to get the modification for.

System.Int32 selectionIndex

The index of the tree target to get the modification for.

System.Boolean childrenHaveModifications

Whether any children of the path have modifications registered.

Returns
UnityEditor.PropertyModification

RegisterPrefabDictionaryAddKeyModification(InspectorProperty, Int32, Object)
Adds an add key modification to the dictionary modifications of a given property.
public void RegisterPrefabDictionaryAddKeyModification(InspectorProperty property, int targetIndex, object key)
Parameters
InspectorProperty property

The property to register a modification for.

System.Int32 targetIndex

Selection index of the target.

System.Object key

The key to be added.

Exceptions
System.ArgumentException

Property " + property.Path + " does not have a value entry; cannot register prefab modification to this property.

RegisterPrefabDictionaryDeltaModification(InspectorProperty, Int32)
Calculates a delta between the current dictionary property and its prefab counterpart, and registers that delta as a Dictionary modification.
public void RegisterPrefabDictionaryDeltaModification(InspectorProperty property, int targetIndex)
Parameters
InspectorProperty property

The property to register a modification for.

System.Int32 targetIndex

Selection index of the target.

Exceptions
System.ArgumentException

Property " + property.Path + " does not have a value entry; cannot register prefab modification to this property.

RegisterPrefabDictionaryRemoveKeyModification(InspectorProperty, Int32, Object)
Adds a remove key modification to the dictionary modifications of a given property.
public void RegisterPrefabDictionaryRemoveKeyModification(InspectorProperty property, int targetIndex, object key)
Parameters
InspectorProperty property

The property to register a modification for.

System.Int32 targetIndex

Selection index of the target.

System.Object key

The key to be removed.

Exceptions
System.ArgumentException

Property " + property.Path + " does not have a value entry; cannot register prefab modification to this property.

RegisterPrefabListLengthModification(InspectorProperty, Int32, Int32)
Registers a modification of type ListLength for a given property.
public void RegisterPrefabListLengthModification(InspectorProperty property, int targetIndex, int newLength)
Parameters
InspectorProperty property

The property to register a modification for.

System.Int32 targetIndex

Selection index of the target to register a modification for.

System.Int32 newLength

The modified list length.

Exceptions
System.ArgumentException

Property " + property.Path + " does not have a value entry; cannot register prefab modification to this property. or newLength cannot be negative!

RegisterPrefabValueModification(InspectorProperty, Int32, Boolean)
Registers a modification of type Value for a given property.
public void RegisterPrefabValueModification(InspectorProperty property, int targetIndex, bool forceImmediate = false)
Parameters
InspectorProperty property

The property to register a modification for.

System.Int32 targetIndex

Selection index of the target to register a modification for.

System.Boolean forceImmediate

Whether to force the change to be registered immediately, rather than at the end of frame.

Exceptions
System.ArgumentException

Property " + property.Path + " does not have a value entry; cannot register prefab modification to this property.

RemovePrefabDictionaryModification(InspectorProperty, Int32, Object)
Removes all dictionary modifications on a property for a given dictionary key value.
public void RemovePrefabDictionaryModification(InspectorProperty property, int targetIndex, object key)
Parameters
InspectorProperty property

The property to remove a key modification for.

System.Int32 targetIndex

Selection index of the target.

System.Object key

The key to remove modifications for.

Exceptions
System.ArgumentNullException

key

RemovePrefabModification(InspectorProperty, Int32, PrefabModificationType)
Removes all prefab modifications of a given type on a given property.
public void RemovePrefabModification(InspectorProperty property, int targetIndex, PrefabModificationType modificationType)
Parameters
InspectorProperty property

The property to remove modifications for.

System.Int32 targetIndex

Selection index of the target.

PrefabModificationType modificationType

Type of the modification to remove.

Update()
public void Update()