docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class XRMarkerSubsystem

    A subsystem that detects and tracks visual markers in the environment (e.g., QR, ArUco, AprilTag).

    Inheritance
    object
    SubsystemWithProvider
    SubsystemWithProvider<XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>
    TrackingSubsystem<XRMarker, XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>
    XRMarkerSubsystem
    Implements
    ISubsystem
    Inherited Members
    TrackingSubsystem<XRMarker, XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>.GetChanges(Allocator)
    SubsystemWithProvider<XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>.OnCreate()
    SubsystemWithProvider<XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>.OnStart()
    SubsystemWithProvider<XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>.OnStop()
    SubsystemWithProvider<XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>.OnDestroy()
    SubsystemWithProvider<XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>.subsystemDescriptor
    SubsystemWithProvider<XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>.provider
    SubsystemWithProvider.Start()
    SubsystemWithProvider.OnStart()
    SubsystemWithProvider.Stop()
    SubsystemWithProvider.OnStop()
    SubsystemWithProvider.Destroy()
    SubsystemWithProvider.OnDestroy()
    SubsystemWithProvider.running
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.XR.ARSubsystems
    Assembly: Unity.XR.ARSubsystems.dll
    Syntax
    public class XRMarkerSubsystem : TrackingSubsystem<XRMarker, XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>, ISubsystem
    Remarks

    This base class must be implemented by providers that supply actual marker detection and tracking.

    Constructors

    XRMarkerSubsystem()

    Do not invoke this constructor directly. Use Unity's subsystem infrastructure to acquire instances.

    Declaration
    public XRMarkerSubsystem()

    Methods

    GetChanges(Allocator)

    Gets the changes (added, updated, and removed markers) since the last call to this method.

    Declaration
    public override TrackableChanges<XRMarker> GetChanges(Allocator allocator)
    Parameters
    Type Name Description
    Allocator allocator

    The allocator used to allocate memory for the changes.

    Returns
    Type Description
    TrackableChanges<XRMarker>

    The set of changes since the last call to this method.

    Overrides
    TrackingSubsystem<XRMarker, XRMarkerSubsystem, XRMarkerSubsystemDescriptor, XRMarkerSubsystem.Provider>.GetChanges(Allocator)

    TryGetBytesData(XRSpatialBuffer)

    Attempts to get the encoded data of a specific marker, decoded as a byte array.

    Declaration
    public Result<byte[]> TryGetBytesData(XRSpatialBuffer dataBuffer)
    Parameters
    Type Name Description
    XRSpatialBuffer dataBuffer

    The spatial buffer of the marker required to retrieve the encoded data.

    Returns
    Type Description
    Result<byte[]>

    A Result which contains the raw byte array if successful.

    Remarks

    To determine if a marker's encoded data is available as binary data, you can check its dataBuffer property. If the bufferType is Uint8, this method should be used to retrieve the encoded data.

    This method allocates a new managed byte[] on each successful call. For performance critical applications that need to avoid garbage collection, consider using (TryGetBytesData(XRSpatialBuffer, Allocator)).

    TryGetBytesData(XRSpatialBuffer, Allocator)

    Attempts to get the encoded data of a specific marker, decoded as a NativeArray_1.

    Declaration
    public Result<NativeArray<byte>> TryGetBytesData(XRSpatialBuffer dataBuffer, Allocator allocator)
    Parameters
    Type Name Description
    XRSpatialBuffer dataBuffer

    The spatial buffer of the marker required to retrieve the encoded data.

    Allocator allocator

    The allocator to use for the returned NativeArray_1.

    Returns
    Type Description
    Result<NativeArray<byte>>

    A Result containing the raw bytes in a NativeArray_1 if the operation is successful.

    Remarks

    This method is useful for performance sensitive applications as it avoids managed memory allocations. The caller is responsible for disposing the returned NativeArray_1 for persistent allocators.

    TryGetStringData(XRSpatialBuffer)

    Attempts to get the encoded data of a specific marker, decoded as a string.

    Declaration
    public Result<string> TryGetStringData(XRSpatialBuffer dataBuffer)
    Parameters
    Type Name Description
    XRSpatialBuffer dataBuffer

    The spatial buffer of the marker required to retrieve the encoded data.

    Returns
    Type Description
    Result<string>

    A Result which contains the decoded string if successful.

    Remarks

    To determine if a marker's encoded data is available as a string, you can check its dataBuffer property. If the bufferType is String, this method should be used to retrieve the encoded data.

    Alternatively, if you expect string data (for example, you are scanning QR codes with URLs), you can call this method directly and check the status to see if it was successful.

    Implements

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