docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class OptionalConverter<T>

    Base UXML attribute converter for Optional<T> values.

    Inheritance
    object
    UxmlAttributeConverter<Optional<T>>
    OptionalConverter<T>
    OptionalColorConverter
    OptionalRectConverter
    OptionalStringConverter
    OptionalValueConverter<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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
    UxmlAttributeConverter<Optional<T>>.FromString(string)

    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
    UnityEditor.UIElements.UxmlAttributeConverter<Unity.AppUI.Core.Optional<T>>.ToString(Unity.AppUI.Core.Optional<T>)

    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 T if parsing failed.

    Returns
    Type Description
    bool

    True if the value could be parsed, False otherwise.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)