public static ARCloudReferencePoint ResolveCloudReferenceId( this ARAnchorManager referencePointManager, string cloudReferenceId) { // Create the underlying ARCore Cloud Anchor. IntPtr cloudAnchorHandle = SessionApi.ResolveCloudAnchor( ARCoreExtensions._instance.currentARCoreSessionHandle, cloudReferenceId); if (cloudAnchorHandle == IntPtr.Zero) { return(null); } // Create the GameObject that is the cloud reference point. ARCloudReferencePoint cloudReferencePoint = (new GameObject(_gameObjectName)).AddComponent <ARCloudReferencePoint>(); if (cloudReferencePoint) { cloudReferencePoint.SetAnchorHandle(cloudAnchorHandle); } // Parent the new cloud reference point to the session origin. cloudReferencePoint.transform.SetParent( ARCoreExtensions._instance.SessionOrigin.trackablesParent, false); return(cloudReferencePoint); }
/// <summary> /// Creates a new local Cloud Anchor from the provided Id. /// <example> /// The sample code below illustrates how to resolve a Cloud Anchor. /// <pre> /// <code> /// private ARCloudAnchor m_CloudAnchor; /// /// void ResolveCloudAnchor(string cloudAnchorId) /// { /// // Request the Cloud Anchor. /// m_CloudAnchor = AnchorManager.ResolveCloudAnchorId(cloudAnchorId); /// } /// /// void Update() /// { /// if (m_CloudAnchor) /// { /// // Check the Cloud Anchor state. /// CloudAnchorState cloudAnchorState = m_CloudAnchor.cloudAnchorState; /// if (cloudAnchorState == CloudAnchorState.Success) /// { /// myOtherGameObject.transform.SetParent(m_CloudAnchor.transform, false); /// m_CloudAnchor = null; /// } /// else if (cloudAnchorState == CloudAnchorState.TaskInProgress) /// { /// // Wait, not ready yet. /// } /// else /// { /// // An error has occurred. /// } /// } /// } /// </code> /// </pre> /// </example> /// </summary> /// <param name="anchorManager">The ARAnchorManager instance for extending. /// </param> /// <param name="cloudAnchorId">String representing the Cloud Anchor.</param> /// <returns>If successful, a <see cref="ARCloudAnchor"/>, /// otherwise <c>null</c>.</returns> public static ARCloudAnchor ResolveCloudAnchorId( this ARAnchorManager anchorManager, string cloudAnchorId) { // Create the underlying ARCore Cloud Anchor. IntPtr cloudAnchorHandle = SessionApi.ResolveCloudAnchor( ARCoreExtensions.Instance.CurrentARCoreSessionHandle, cloudAnchorId); if (cloudAnchorHandle == IntPtr.Zero) { return(null); } // Create the GameObject that is the Cloud Anchor. ARCloudAnchor cloudAnchor = (new GameObject(k_GameObjectName)).AddComponent <ARCloudAnchor>(); if (cloudAnchor) { cloudAnchor.SetAnchorHandle(cloudAnchorHandle); } // Parent the new Cloud Anchor to the session origin. cloudAnchor.transform.SetParent( ARCoreExtensions.Instance.SessionOrigin.trackablesParent, false); return(cloudAnchor); }