示例#1
0
        /// <summary>
        /// Resolves an anchor id and instantiates an Anchor prefab on it.
        /// </summary>
        /// <param name="cloudAnchorId">Cloud anchor id to be resolved.</param>
        private void _ResolveAnchorFromId(string cloudAnchorId)
        {
            m_CloudAnchorsExampleController.OnAnchorInstantiated(false);

            // If device is not tracking, let's wait to try to resolve the anchor.
            if (Session.Status != SessionStatus.Tracking)
            {
                return;
            }

            m_ShouldResolve = false;

            XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction((System.Action <CloudAnchorResult>)(result =>
            {
                if (result.Response != CloudServiceResponse.Success)
                {
                    Debug.LogError(string.Format("Client could not resolve Cloud Anchor {0}: {1}",
                                                 cloudAnchorId, result.Response));

                    m_CloudAnchorsExampleController.OnAnchorResolved(false, result.Response.ToString());
                    m_ShouldResolve = true;
                    return;
                }

                Debug.Log(string.Format("Client successfully resolved Cloud Anchor {0}.",
                                        cloudAnchorId));

                m_CloudAnchorsExampleController.OnAnchorResolved(true, result.Response.ToString());
                _OnResolved(result.Anchor.transform);
            }));
        }
        /// <summary>
        /// Resolves an anchor id and instantiates an Anchor prefab on it.
        /// </summary>
        /// <param name="cloudAnchorId">Cloud anchor id to be resolved.</param>
        private void _ResolveAnchorFromId(string cloudAnchorId)
        {
            m_CloudAnchorsExampleController.OnAnchorInstantiated(false);

            // If device is not tracking, let's wait to try to resolve the anchor.
            if (Session.Status != SessionStatus.Tracking)
            {
                return;
            }

            m_ShouldResolve = false;
            Debug.Log("###### resolving anchor");
            XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction(
                (System.Action <CloudAnchorResult>)(result =>
            {
                if (result.Response != CloudServiceResponse.Success)
                {
                    Debug.LogError(string.Format(
                                       "##### Client could not resolve Cloud Anchor {0}: {1}",
                                       cloudAnchorId, result.Response));

                    m_CloudAnchorsExampleController.OnAnchorResolved(
                        false, result.Response.ToString());
                    // The response will rail in the editor. There is no need to try to resolve it again.
#if !UNITY_EDITOR
                    m_ShouldResolve = true;
#endif
                    return;
                }

                Debug.Log(string.Format(
                              "##### Client successfully resolved Cloud Anchor {0}.",
                              cloudAnchorId));

                m_CloudAnchorsExampleController.OnAnchorResolved(
                    true, result.Response.ToString());
                _OnResolved(result.Anchor.transform);
                m_AnchorMesh.SetActive(true);
            }));
        }