Exemplo n.º 1
0
        public GoogleARCore.AsyncTask <CloudAnchorResult> CreateCloudAnchor(GoogleARCore.Anchor anchor)
        {
            Action <CloudAnchorResult> onComplete;
            var task = new GoogleARCore.AsyncTask <CloudAnchorResult>(out onComplete);

            IntPtr cloudAnchorHandle = IntPtr.Zero;
            var    status            = LifecycleManager.Instance.NativeSession.SessionApi
                                       .CreateCloudAnchor(anchor.m_NativeHandle, out cloudAnchorHandle);

            if (status != ApiArStatus.Success)
            {
                onComplete(new CloudAnchorResult()
                {
                    Response = status.ToCloudServiceResponse(),
                    Anchor   = null,
                });

                return(task);
            }

            var request = new CloudAnchorRequest()
            {
                IsComplete     = false,
                NativeSession  = LifecycleManager.Instance.NativeSession,
                AnchorHandle   = cloudAnchorHandle,
                OnTaskComplete = onComplete,
            };

            _UpdateCloudAnchorRequest(request, true);
            return(task);
        }
Exemplo n.º 2
0
        public GoogleARCore.AsyncTask <CloudAnchorResult> CreateCloudAnchor(UnityEngine.Pose pose)
        {
            Action <CloudAnchorResult> onComplete;
            var task = new GoogleARCore.AsyncTask <CloudAnchorResult>(out onComplete);

            if (LifecycleManager.Instance.NativeSession == null)
            {
                onComplete(new CloudAnchorResult()
                {
                    Response = CloudServiceResponse.ErrorNotSupportedByConfiguration,
                    Anchor   = null,
                });

                return(task);
            }

            var    poseHandle        = LifecycleManager.Instance.NativeSession.PoseApi.Create(pose);
            IntPtr arkitAnchorHandle = IntPtr.Zero;

            ExternApi.ARKitAnchor_create(poseHandle, ref arkitAnchorHandle);

            IntPtr cloudAnchorHandle = IntPtr.Zero;
            var    status            = LifecycleManager.Instance.NativeSession.SessionApi
                                       .CreateCloudAnchor(arkitAnchorHandle, out cloudAnchorHandle);

            LifecycleManager.Instance.NativeSession.PoseApi.Destroy(poseHandle);
            ExternApi.ARKitAnchor_release(arkitAnchorHandle);

            if (status != ApiArStatus.Success)
            {
                onComplete(new CloudAnchorResult()
                {
                    Response = status.ToCloudServiceResponse(),
                    Anchor   = null,
                });

                return(task);
            }

            var request = new CloudAnchorRequest()
            {
                IsComplete     = false,
                NativeSession  = LifecycleManager.Instance.NativeSession,
                AnchorHandle   = cloudAnchorHandle,
                OnTaskComplete = onComplete,
            };

            _UpdateCloudAnchorRequest(request, true);
            return(task);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Helper for creating and initializing the Action and AsyncTask for CloudAnchorResult.
 /// </summary>
 /// <param name="onComplete">The on complete Action initialized from the AsyncTask.
 /// This will always contain a valid task even when function returns false.</param>
 /// <param name="task">The created task.
 /// This will always contain a valid task even when function returns false.</param>
 /// <returns>Returns true if cloud anchor creation should continue. Returns false if cloud creation
 /// should abort.</returns>
 protected internal bool _CreateCloudAnchorResultAsyncTask(out Action <CloudAnchorResult> onComplete,
                                                           out GoogleARCore.AsyncTask <CloudAnchorResult> task)
 {
     // Action<CloudAnchorResult> onComplete;
     task = new GoogleARCore.AsyncTask <CloudAnchorResult>(out onComplete);
     if (LifecycleManager.Instance.NativeSession == null)
     {
         onComplete(new CloudAnchorResult()
         {
             Response = CloudServiceResponse.ErrorNotSupportedByConfiguration,
             Anchor   = null,
         });
         return(false);
     }
     return(true);
 }
Exemplo n.º 4
0
        public GoogleARCore.AsyncTask <CloudAnchorResult> ResolveCloudAnchor(String cloudAnchorId)
        {
            Action <CloudAnchorResult> onComplete;
            var task = new GoogleARCore.AsyncTask <CloudAnchorResult>(out onComplete);

            if (LifecycleManager.Instance.NativeSession == null)
            {
                onComplete(new CloudAnchorResult()
                {
                    Response = CloudServiceResponse.ErrorNotSupportedByConfiguration,
                    Anchor   = null,
                });

                return(task);
            }

            IntPtr cloudAnchorHandle = IntPtr.Zero;
            var    status            = LifecycleManager.Instance.NativeSession.SessionApi
                                       .ResolveCloudAnchor(cloudAnchorId, out cloudAnchorHandle);

            if (status != ApiArStatus.Success)
            {
                onComplete(new CloudAnchorResult()
                {
                    Response = status.ToCloudServiceResponse(),
                    Anchor   = null,
                });

                return(task);
            }

            var request = new CloudAnchorRequest()
            {
                IsComplete     = false,
                NativeSession  = LifecycleManager.Instance.NativeSession,
                AnchorHandle   = cloudAnchorHandle,
                OnTaskComplete = onComplete,
            };

            _UpdateCloudAnchorRequest(request, true);
            return(task);
        }