Google is committed to advancing racial equity for Black communities. See how.

Google.XR.ARCoreExtensions.ARAnchorManagerExtensions

Extensions to AR Foundation's ARAnchorManager class.

Summary

Public static functions

AddCloudReferencePoint(this ARAnchorManager referencePointManager, ARAnchor referencePoint) Deprecated. Please use HostCloudAnchor(ARAnchor) instead.
Creates a new cloud reference point using an existing local Reference Point.
EstimateFeatureMapQualityForHosting(this ARAnchorManager anchorManager, Pose pose)
Estimates the quality of the visual feature points seen by ARCore in the preceding few seconds and visible from the provided camera pose .
HostCloudAnchor(this ARAnchorManager anchorManager, ARAnchor anchor)
Creates a new Cloud Anchor using an existing local ARAnchor.
HostCloudAnchor(this ARAnchorManager anchorManager, ARAnchor anchor, int ttlDays)
Creates a new Cloud Anchor with a given lifetime using an existing local ARAnchor.
ResolveCloudAnchorId(this ARAnchorManager anchorManager, string cloudAnchorId)
Creates a new local Cloud Anchor from the provided Id.
ResolveCloudReferenceId(this ARAnchorManager referencePointManager, string cloudReferenceId) Deprecated. Please use ResolveCloudAnchorId(string) instead.
Creates a new local cloud reference point from the provided Id.
SetAuthToken(this ARAnchorManager anchorManager, string authToken)
void
Set the token to use when authenticating with the ARCore Cloud Anchor service on the iOS platform.

Public static functions

AddCloudReferencePoint

ARCloudReferencePoint AddCloudReferencePoint(
  this ARAnchorManager referencePointManager,
  ARAnchor referencePoint
)

Creates a new cloud reference point using an existing local Reference Point.

Deprecated. Please use HostCloudAnchor(ARAnchor) instead.

Details
Parameters
referencePointManager
The ARAnchorManager instance.
referencePoint
The local ARAnchor to be used as the basis to host a new cloud reference point.
Returns
If successful, a ARCloudReferencePoint, otherwise null.

EstimateFeatureMapQualityForHosting

FeatureMapQuality EstimateFeatureMapQualityForHosting(
  this ARAnchorManager anchorManager,
  Pose pose
)

Estimates the quality of the visual feature points seen by ARCore in the preceding few seconds and visible from the provided camera pose .

Cloud Anchors hosted using higher feature map quality will generally result in easier and more accurately resolved ARCloudAnchor poses. If feature map quality cannot be estimated for the given pose , a warning message "Failed to estimate feature map quality" with the error status is logged and FeatureMapQuality.Insufficient is returned.

Details
Parameters
anchorManager
The ARAnchorManager instance.
pose
The camera pose to use in estimating the quality.
Returns
The estimated feature map quality.

HostCloudAnchor

ARCloudAnchor HostCloudAnchor(
  this ARAnchorManager anchorManager,
  ARAnchor anchor
)

Creates a new Cloud Anchor using an existing local ARAnchor.

The sample code below illustrates how to host a Cloud Anchor.


private ARCloudAnchor _cloudAnchor;

void HostCloudAnchor(Pose pose)
{
    // Create a local anchor, you may also use another ARAnchor you already have.
    ARAnchor localAnchor = AnchorManager.AddAnchor(pose);

    // Request the Cloud Anchor.
    _cloudAnchor = AnchorManager.HostCloudAnchor(localAnchor);
}

void Update()
{
    if (_cloudAnchor)
    {
        // Check the Cloud Anchor state.
        CloudAnchorState cloudAnchorState = _cloudAnchor.cloudAnchorState;
        if (cloudAnchorState == CloudAnchorState.Success)
        {
            myOtherGameObject.transform.SetParent(_cloudAnchor.transform, false);
            _cloudAnchor = null;
        }
        else if (cloudAnchorState == CloudAnchorState.TaskInProgress)
        {
            // Wait, not ready yet.
        }
        else
        {
            // An error has occurred.
        }
    }
}

Details
Parameters
anchorManager
The ARAnchorManager instance.
anchor
The local ARAnchor to be used as the basis to host a new Cloud Anchor.
Returns
If successful, a ARCloudAnchor, otherwise null.

HostCloudAnchor

ARCloudAnchor HostCloudAnchor(
  this ARAnchorManager anchorManager,
  ARAnchor anchor,
  int ttlDays
)

Creates a new Cloud Anchor with a given lifetime using an existing local ARAnchor.

Details
Parameters
anchorManager
The ARAnchorManager instance.
anchor
The local ARAnchor to be used as the basis to host a new Cloud Anchor.
ttlDays
The lifetime of the anchor in days. Must be positive. The maximum allowed value is 1 if using an API Key to authenticate with the ARCore Cloud Anchor service, otherwise the maximum allowed value is 365.
Returns
If successful, an ARCloudAnchor, otherwise null.

ResolveCloudAnchorId

ARCloudAnchor ResolveCloudAnchorId(
  this ARAnchorManager anchorManager,
  string cloudAnchorId
)

Creates a new local Cloud Anchor from the provided Id.

The sample code below illustrates how to resolve a Cloud Anchor.


private ARCloudAnchor _cloudAnchor;

void ResolveCloudAnchor(string cloudAnchorId)
{
    // Request the Cloud Anchor.
    _cloudAnchor = AnchorManager.ResolveCloudAnchorId(cloudAnchorId);
}

void Update()
{
    if (_cloudAnchor)
    {
        // Check the Cloud Anchor state.
        CloudAnchorState cloudAnchorState = _cloudAnchor.cloudAnchorState;
        if (cloudAnchorState == CloudAnchorState.Success)
        {
            myOtherGameObject.transform.SetParent(_cloudAnchor.transform, false);
            _cloudAnchor = null;
        }
        else if (cloudAnchorState == CloudAnchorState.TaskInProgress)
        {
            // Wait, not ready yet.
        }
        else
        {
            // An error has occurred.
        }
    }
}

Details
Parameters
anchorManager
The ARAnchorManager instance.
cloudAnchorId
String representing the Cloud Anchor.
Returns
If successful, a ARCloudAnchor, otherwise null.

ResolveCloudReferenceId

ARCloudReferencePoint ResolveCloudReferenceId(
  this ARAnchorManager referencePointManager,
  string cloudReferenceId
)

Creates a new local cloud reference point from the provided Id.

Deprecated. Please use ResolveCloudAnchorId(string) instead.

Details
Parameters
referencePointManager
The ARAnchorManager instance.
cloudReferenceId
String representing the cloud reference.
Returns
If successful, a ARCloudReferencePoint, otherwise null.

SetAuthToken

void SetAuthToken(
  this ARAnchorManager anchorManager,
  string authToken
)

Set the token to use when authenticating with the ARCore Cloud Anchor service on the iOS platform.

This should be called each time the application's token is refreshed.

Details
Parameters
anchorManager
The ARAnchorManager instance.
authToken
The authentication token to set.