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
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. |
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. |
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. |
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. |
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 |
---|---|
Boolean | 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 |
---|---|
Boolean | 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. |
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. |
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 |
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 |