docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct XRMarker

    Represents a marker detected by the marker subsystem.

    Implements
    ITrackable
    IEquatable<XRMarker>
    Inherited Members
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.ARSubsystems
    Assembly: Unity.XR.ARSubsystems.dll
    Syntax
    public struct XRMarker : ITrackable, IEquatable<XRMarker>

    Constructors

    XRMarker(TrackableId, Pose, TrackingState, IntPtr, Vector2, XRMarkerType, int, XRSpatialBuffer, TrackableId)

    Constructs a new XRMarker.

    Declaration
    public XRMarker(TrackableId trackableId, Pose pose, TrackingState trackingState, IntPtr nativePtr, Vector2 size, XRMarkerType markerType, int markerId, XRSpatialBuffer dataBuffer, TrackableId parentId)
    Parameters
    Type Name Description
    TrackableId trackableId

    The unique identifier for the marker.

    Pose pose

    The marker's pose in session space.

    TrackingState trackingState

    Tracking status.

    IntPtr nativePtr

    Provider-specific native pointer, or Zero.

    Vector2 size

    The detected marker size.

    XRMarkerType markerType

    Type/classification of marker.

    int markerId

    Integer identifier.

    XRSpatialBuffer dataBuffer

    Optional buffer for marker-specific data encoded data.

    TrackableId parentId

    The TrackableId of the parent of this tracked object.

    Properties

    dataBuffer

    The marker's data buffer.

    Declaration
    public readonly XRSpatialBuffer dataBuffer { get; }
    Property Value
    Type Description
    XRSpatialBuffer
    Remarks

    Only valid if markerType is QRCode or MicroQRCode.

    To safely access the encoded data, you should first check the bufferType of this buffer. When the runtime successfully decodes a marker's encoded data, it sets the bufferType to either String or Uint8 and assigns a valid bufferId. If the bufferType is one of these values, you can then use TryGetStringData(XRSpatialBuffer) or TryGetBytesData(XRSpatialBuffer) to retrieve the data.

    defaultValue

    Gets a default-initialized XRMarker.

    Declaration
    public static XRMarker defaultValue { get; }
    Property Value
    Type Description
    XRMarker

    markerId

    If markerType is ArUco or AprilTag, this property gets the integer ID encoded by the marker. Otherwise, 0.

    Declaration
    public readonly int markerId { get; }
    Property Value
    Type Description
    int

    markerType

    The type of marker that was detected.

    Declaration
    public readonly XRMarkerType markerType { get; }
    Property Value
    Type Description
    XRMarkerType

    nativePtr

    A native pointer to additional provider-specific data. May be Zero.

    Declaration
    public readonly IntPtr nativePtr { get; }
    Property Value
    Type Description
    IntPtr

    parentId

    The TrackableId of the parent of this tracked object.

    Declaration
    public readonly TrackableId parentId { get; }
    Property Value
    Type Description
    TrackableId

    pose

    The pose of the marker in the session space.

    Declaration
    public readonly Pose pose { get; }
    Property Value
    Type Description
    Pose
    Remarks

    The Pose is oriented so that its local positive Y-axis (up) points directly away from the front face of the marker, perpendicular to its surface.

    size

    The logical size of the detected marker, in meters.

    Declaration
    public readonly Vector2 size { get; }
    Property Value
    Type Description
    Vector2
    Remarks

    This value represents the width and height of the marker. The X component (size.x) represents the width and corresponds to the marker's local X-axis. The Y component (size.y) represents the height and corresponds to the marker's local Z-axis.

    trackableId

    The unique identifier for this marker.

    Declaration
    public readonly TrackableId trackableId { get; }
    Property Value
    Type Description
    TrackableId

    trackingState

    The current tracking state of the marker.

    Declaration
    public readonly TrackingState trackingState { get; }
    Property Value
    Type Description
    TrackingState

    Methods

    Equals(object)

    Determines whether the specified object is equal to the current object.

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

    The object to compare with the current object.

    Returns
    Type Description
    bool

    true if the obj is an XRMarker and all properties match; otherwise, false.

    Overrides
    ValueType.Equals(object)

    Equals(XRMarker)

    Indicates whether every field in this XRMarker is equal to the corresponding field in other.

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

    The XRMarker to compare with.

    Returns
    Type Description
    bool

    true if all properties match; otherwise, false.

    GetHashCode()

    Serves as the default hash function.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    The hash value of this marker.

    Overrides
    ValueType.GetHashCode()

    Operators

    operator ==(XRMarker, XRMarker)

    Determines whether two XRMarker instances have exactly the same property values.

    Declaration
    public static bool operator ==(XRMarker left, XRMarker right)
    Parameters
    Type Name Description
    XRMarker left

    The first marker to compare.

    XRMarker right

    The second marker to compare.

    Returns
    Type Description
    bool

    true if all properties match; otherwise, false.

    operator !=(XRMarker, XRMarker)

    Determines whether two XRMarker instances have different property values.

    Declaration
    public static bool operator !=(XRMarker left, XRMarker right)
    Parameters
    Type Name Description
    XRMarker left

    The first marker to compare.

    XRMarker right

    The second marker to compare.

    Returns
    Type Description
    bool

    true if any property differs; otherwise, false.

    Implements

    ITrackable
    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)