Class OptionalConverter<T>
Base UXML attribute converter for Optional<T> values.
Inherited Members
Namespace: Unity.AppUI.Editor
Assembly: Unity.AppUI.Editor.dll
Syntax
public abstract class OptionalConverter<T> : UxmlAttributeConverter<Optional<T>>
Type Parameters
| Name | Description |
|---|---|
| T | The type of the value wrapped by the Optional<T>. |
Remarks
An empty or unparsable attribute value is converted to none, so an attribute that is absent from the UXML behaves the same as one left blank.
Methods
FromString(string)
Converts a UXML attribute value into an Optional<T>.
Declaration
public override Optional<T> FromString(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The attribute value to convert. |
Returns
| Type | Description |
|---|---|
| Optional<T> | The converted value, or none if it is empty or cannot be parsed. |
Overrides
ToString(Optional<T>)
Converts an Optional<T> into its UXML attribute representation.
Declaration
public override string ToString(Optional<T> value)
Parameters
| Type | Name | Description |
|---|---|---|
| Optional<T> | value | The value to convert. |
Returns
| Type | Description |
|---|---|
| string | The string representation of the wrapped value, or an empty string if no value is set. |
Overrides
TryParse(string, out T)
Tries to parse the string representation of the wrapped value.
Declaration
protected virtual bool TryParse(string value, out T v)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string to parse. |
| T | v | The parsed value, or the default value of |
Returns
| Type | Description |
|---|---|
| bool | True if the value could be parsed, False otherwise. |