docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct Result<T>

    Represents the result of a completed operation that attempted to create an object of type T.

    Implements
    IEquatable<XRResultStatus>
    IEquatable<Result<T>>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.ARSubsystems
    Assembly: Unity.XR.ARSubsystems.dll
    Syntax
    public struct Result<T> : IEquatable<XRResultStatus>, IEquatable<Result<T>>
    Type Parameters
    Name Description
    T

    The result type.

    Constructors

    Result(XRResultStatus, T)

    Construct an instance with a given status and value.

    Declaration
    public Result(XRResultStatus status, T value)
    Parameters
    Type Name Description
    XRResultStatus status

    The status.

    T value

    The result value.

    Result(T)

    Construct a result containing an unqualified success status code and the given value.

    Declaration
    public Result(T value)
    Parameters
    Type Name Description
    T value

    The value.

    Properties

    status

    The status of the completed operation. You should check whether the operation was successful before you access the result value.

    Declaration
    public XRResultStatus status { get; }
    Property Value
    Type Description
    XRResultStatus

    value

    The result value of the completed operation. Only valid if status.IsSuccess() is true.

    Declaration
    public T value { get; }
    Property Value
    Type Description
    T
    Remarks
    Important

    If the operation was unsuccessful, you should not access this value. It may be null or could contain default data.

    Methods

    Equals(object)

    Compare for equality with another object.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    The object.

    Returns
    Type Description
    bool

    true if obj is either of type Result<T> or XRResultStatus, and compares equal using one of the other overloads of this function.

    Overrides
    ValueType.Equals(object)

    Equals(Result<T>)

    Compare for equality with another instance.

    Declaration
    public bool Equals(Result<T> other)
    Parameters
    Type Name Description
    Result<T> other

    The other instance.

    Returns
    Type Description
    bool

    true if the instances are equal. Otherwise, false.

    Equals(XRResultStatus)

    Compares for equality with an XRResultStatus instance.

    Declaration
    public bool Equals(XRResultStatus other)
    Parameters
    Type Name Description
    XRResultStatus other

    The XRResultStatus.

    Returns
    Type Description
    bool

    true if the instances are equal. Otherwise, false.

    Remarks

    A Result<T> compares equal to an XRResultStatus only if it represents an error, and its status value is equal to the given XRResultStatus.

    GetHashCode()

    Get a hash code for this instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    The hash code.

    Overrides
    ValueType.GetHashCode()

    ToString()

    Returns a string suitable for debugging purposes.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    The string.

    Overrides
    ValueType.ToString()

    Implements

    IEquatable<T>
    IEquatable<T>
    In This Article
    Back to top
    Copyright © 2025 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)