Class BindingContextElement
Base class for elements that can generate a UI hierarchy for a given object.
Inheritance
Implements
Inherited Members
Namespace: Unity.Properties.UI
Assembly: Unity.Properties.UI.Editor.dll
Syntax
public abstract class BindingContextElement : BindableElement, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IBindable
Methods
AddContext(InspectionContext)
Adds an inspection context to this element.
Declaration
public void AddContext(InspectionContext inspectionContext)
Parameters
Type | Name | Description |
---|---|---|
InspectionContext | inspectionContext | The inspection context to add. |
Exceptions
Type | Condition |
---|---|
NullReferenceException | The inspection context is null. |
ClearTarget()
Clears the current target and removes all child elements from this element's contentContainer.
Declaration
public void ClearTarget()
ForceReload()
Clears the current children and re-generates them.
Declaration
public void ForceReload()
GetContext<T>(string)
Returns an inspection context of the given type.
Declaration
public T GetContext<T>(string contextName = null) where T : InspectionContext
Parameters
Type | Name | Description |
---|---|---|
string | contextName | The name of the inspection context. |
Returns
Type | Description |
---|---|
T | The inspection context, if it exists. |
Type Parameters
Name | Description |
---|---|
T | The inspection context type. |
GetTargetType()
Returns the type of the current target.
Declaration
public Type GetTargetType()
Returns
Type | Description |
---|---|
Type | The type of the target. |
GetTarget<T>()
Gets the target of the BindingContextElement as T.
Declaration
public T GetTarget<T>()
Returns
Type | Description |
---|---|
T | The instance of the target. |
Type Parameters
Name | Description |
---|---|
T | The type of the target. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when no target has been set. |
InvalidCastException | Thrown when the target is not of type T. |
GetValue<TValue>(PropertyPath)
Gets the value of type TValue at the given path.
Declaration
public TValue GetValue<TValue>(PropertyPath path)
Parameters
Type | Name | Description |
---|---|---|
PropertyPath | path | The property path to the value. |
Returns
Type | Description |
---|---|
TValue | The value at path. |
Type Parameters
Name | Description |
---|---|
TValue | The value type. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when no target has been set. |
HasContext<T>(string)
Returns true if an inspection context of the given type exists.
Declaration
public bool HasContext<T>(string contextName = null) where T : InspectionContext
Parameters
Type | Name | Description |
---|---|---|
string | contextName | The name of the inspection context. |
Returns
Type | Description |
---|---|
bool | true, if it exists. |
Type Parameters
Name | Description |
---|---|
T | The inspection context type. |
IsPathValid(PropertyPath)
Returns true if the given path is valid from the target.
Declaration
public bool IsPathValid(PropertyPath path)
Parameters
Type | Name | Description |
---|---|---|
PropertyPath | path | the property path. |
Returns
Type | Description |
---|---|
bool | true if the path is valid. |
RemoveContext(InspectionContext)
Removes an inspection context from this element.
Declaration
public void RemoveContext(InspectionContext inspectionContext)
Parameters
Type | Name | Description |
---|---|---|
InspectionContext | inspectionContext | The inspection context to add. |
Exceptions
Type | Condition |
---|---|
NullReferenceException | The inspection context is null. |
ArgumentException | The inspection context was not previously added. |
SetAttributeFilter(AttributeFilterHandler)
Allows to filter the hierarchy generation based on the field's attributes.
Declaration
public void SetAttributeFilter(BindingContextElement.AttributeFilterHandler filter)
Parameters
Type | Name | Description |
---|---|---|
BindingContextElement.AttributeFilterHandler | filter | The filter method to apply. |
SetTarget<T>(T)
Sets the current target.
Declaration
public void SetTarget<T>(T target)
Parameters
Type | Name | Description |
---|---|---|
T | target | The target to set. |
Type Parameters
Name | Description |
---|---|
T | The type of the target. |
Remarks
This will clear current hierarchy and regenerate a new one.
SetValue<TValue>(PropertyPath, TValue)
Sets the value of type TValue at the given path.
Declaration
public void SetValue<TValue>(PropertyPath path, TValue value)
Parameters
Type | Name | Description |
---|---|---|
PropertyPath | path | The property path to the value. |
TValue | value | the value we want to set. |
Type Parameters
Name | Description |
---|---|
TValue | The value type. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when no target has been set. |
TryGetTarget<T>(out T)
Tries to get the target of the BindingContextElement as an instance of type T.
Declaration
public bool TryGetTarget<T>(out T target)
Parameters
Type | Name | Description |
---|---|---|
T | target | The target instance. |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T | The type of the target. |
TryGetValue<TValue>(PropertyPath, out TValue)
Tries to get the value of type TValue at the given path.
Declaration
public bool TryGetValue<TValue>(PropertyPath path, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
PropertyPath | path | The property path to the value. |
TValue | value | The value at path. |
Returns
Type | Description |
---|---|
bool | true if the getting the value was successful. |
Type Parameters
Name | Description |
---|---|
TValue | The value type. |
TrySetValue<TValue>(PropertyPath, TValue)
Tries to set the value of type TValue at the given path.
Declaration
public bool TrySetValue<TValue>(PropertyPath path, TValue value)
Parameters
Type | Name | Description |
---|---|---|
PropertyPath | path | The property path to the value. |
TValue | value | the value we want to set. |
Returns
Type | Description |
---|---|
bool | The value that was effectively set. |
Type Parameters
Name | Description |
---|---|
TValue | The value type. |
Events
OnChanged
Register to this event to be notified when a change is detected.
Declaration
public event BindingContextElement.ChangeHandler OnChanged
Event Type
Type | Description |
---|---|
BindingContextElement.ChangeHandler |