docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Anchors

    This page is a supplement to the AR Foundation Anchors manual. The following sections only contain information about APIs where Meta Quest exhibits unique platform-specific behavior.

    Tip

    When developing an AR app, refer to both the AR Foundation documentation as well as the required packages for each platform you support.

    Optional feature support

    Meta OpenXR implements the following optional features of AR Foundation's XRAnchorSubsystem:

    Feature Descriptor Property Supported
    Trackable Attachment supportsTrackableAttachments
    Synchronous Add Anchor supportsSynchronousAdd
    Save Anchor supportsSaveAnchor Yes
    Load Anchor supportsLoadAnchor Yes
    Erase Anchor supportsEraseAnchor Yes
    Get Saved Anchor Ids supportsGetSavedAnchorIds
    Async Cancellation supportsAsyncCancellation

    Platform-specific success and error codes

    On OpenXR platforms, the XRResultStatus.nativeStatusCode returned by AR Foundation's ARAnchorManager.TryAddAnchorAsync is a wrapper around OpenXR's XrResult.

    You can use the XRResultStatus.nativeStatusCode property to access the underlying XrResult value, as shown in the example below:

    // This is not optimal. For better performance, reuse a saved reference instead.
    var anchorManager = Object.FindAnyObjectByType<ARAnchorManager>();
    
    // Create an anchor at an arbitrary pose.
    // You could modify this code to use the position of a raycast hit instead.
    var pose = new Pose(Vector3.zero, Quaternion.identity);
    var result = await anchorManager.TryAddAnchorAsync(pose);
    
    // To access OpenXR error and success codes, use the nativeStatusCode property
    var xrResult = (XrResult)result.status.nativeStatusCode;
    
    // Prints "Success", or the error or success code associated with this operation
    Debug.Log(xrResult);
    

    Persistent anchor GUIDs

    On Meta's OpenXR runtime, the SerializableGuid returned by ARAnchorManager.TrySaveAnchorAsync is the same value as the input anchor's trackableId.

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