Class PropertyElement
Makes an element that can generate a UI hierarchy for a given target.
Namespace: Unity.Properties.UI
Syntax
public sealed class PropertyElement : BindableElement
Constructors
PropertyElement()
Constructs an instance of PropertyElement.
Declaration
public PropertyElement()
Methods
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()
GetTarget<T>()
Gets the target of the PropertyElement as
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 |
GetValue<TValue>(PropertyPath)
Gets the value of type
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. |
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 |
|---|---|
| Boolean | true if the path is valid. |
SetAttributeFilter(PropertyElement.AttributeFilterHandler)
Allows to filter the hierarchy generation based on the field's attributes.
Declaration
public void SetAttributeFilter(PropertyElement.AttributeFilterHandler filter)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyElement.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
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 PropertyElement as an instance of type
Declaration
public bool TryGetTarget<T>(out T target)
Parameters
| Type | Name | Description |
|---|---|---|
| T | target | The target instance. |
Returns
| Type | Description |
|---|---|
| Boolean | true if target was of the correct type; false otherwise. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the target. |
TryGetValue<TValue>(PropertyPath, out TValue)
Tries to get the value of type
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 |
|---|---|
| Boolean | 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
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 |
|---|---|
| Boolean | 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 PropertyElement.ChangeHandler OnChanged
Event Type
| Type | Description |
|---|---|
| PropertyElement.ChangeHandler |