コード例 #1
0
 private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
 {
     if (completionReason != SerializationCompletionReason.Succeeded)
     {
         Debug.Log("Failed to import: " + completionReason.ToString());
         if (retryCount > 0)
         {
             indicator.GetComponent <MeshRenderer>().material.color = Color.cyan;
             WorldAnchorTransferBatch.ImportAsync(anchorData, OnImportComplete);
         }
         return;
     }
     if (deserializedTransferBatch.GetAllIds().Length == 0)
     {
         if (retryCount > 0)
         {
             indicator.GetComponent <MeshRenderer>().material.color = Color.cyan;
             WorldAnchorTransferBatch.ImportAsync(anchorData, OnImportComplete);
         }
         return;
     }
     if (gameObject != null)
     {
         indicator.GetComponent <MeshRenderer>().material.color = Color.green;
         deserializedTransferBatch.LockObject(gameObject.name, gameObject);
         transform.parent.GetComponent <SetRefObjToCertain>().totalSyncNum++;
         gameObject.SetActive(true);
     }
     else
     {
         indicator.GetComponent <MeshRenderer>().material.color = Color.red;
     }
 }
コード例 #2
0
    /// <summary>
    /// Called when a remote anchor has been deserialized
    /// </summary>
    /// <param name="status"></param>
    /// <param name="wat"></param>
    private void OnImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch wat)
    {
        if (status == SerializationCompletionReason.Succeeded && wat.GetAllIds().Length > 0)
        {
            Debug.Log("Import complete");

            string first = wat.GetAllIds()[0];
            Debug.Log("Anchor name: " + first);

            // Try zeroing out the local position & rotation

            gameObject.transform.localPosition = new Vector3();
            gameObject.transform.localRotation = new Quaternion();

            WorldAnchor anchor = wat.LockObject(first, gameObject);
            currentState = ImportExportState.Ready;

            if (audioSource != null)
            {
                audioSource.Play();
            }
        }
        else
        {
            Debug.Log("Import fail");
            currentState = ImportExportState.DataReady;
        }
    }
コード例 #3
0
    private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
    {
        if (completionReason != SerializationCompletionReason.Succeeded)
        {
            Debug.Log("Failed to import: " + completionReason.ToString());
            if (retryCount > 0)
            {
                retryCount--;
                indicator.GetComponent <MeshRenderer>().material.color = Color.cyan;
                WorldAnchorTransferBatch.ImportAsync(anchorData, OnImportComplete);
            }
            return;
        }

        GameObject sr = GameObject.Find("RefernceSceneBuilder");

        if (sr != null)
        {
            deserializedTransferBatch.LockObject("1_GC35L", sr);
            CompleteWaTime.text = Time.time.ToString();
            SendMsg sendstr = new SendMsg("SyncPlantNum:" + IF.text);
            startSocketTime.text = Time.time.ToString();
            tCP.SocketSendByte(sendstr);
        }
        else
        {
            Debug.Log("Failed to find object for anchor id: " + "1_GC35L");
            indicator.GetComponent <MeshRenderer>().material.color = Color.red;
        }
    }
コード例 #4
0
    private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch wat)
    {
        if (completionReason == SerializationCompletionReason.Succeeded)
        {
            Logger.Log("World Anchor Import Complete (succeeded)");

            if (wat.GetAllIds().Length > 0)
            {
                string first = wat.GetAllIds()[0];
                Logger.Log("Anchor name: " + first);

                WorldAnchor anchor = wat.LockObject(first, rootSharedObject);
                rootSharedObject.transform.position += anchor.transform.position;

                Logger.Log("Game Object " + gameObject.name + " locked with world anchor " + anchor != null ? anchor.name : "NULL");

                if (WorldAnchorStore != null)
                {
                    WorldAnchorStore.Save(first, anchor);
                }
            }
        }
        else
        {
            Logger.Log("World Anchor Import Failed - reason " + completionReason);
        }
    }
コード例 #5
0
        //导入完成后,把锚点数据附加到 物体上
        private void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch wat)
        {
            MYDialog.Instance.Write(status.ToString() + wat.GetAllIds().Length);
            if (status == SerializationCompletionReason.Succeeded && wat.GetAllIds().Length > 0)
            {
                MYDialog.Instance.Write("\r\n导入完成!");
                string first = wat.GetAllIds()[0];
                Debug.Log("锚点名字: " + first);
                WorldAnchor existingAnchor = objectToImportAnchor.GetComponent <WorldAnchor>();
                if (existingAnchor != null)
                {
                    //删除旧的锚点数据
                    DestroyImmediate(existingAnchor);
                }
                //绑定新的锚点数据
                Debug.Log(objectToImportAnchor.transform.position);
                WorldAnchor anchor = wat.LockObject(first, objectToImportAnchor);
                //AnchorStore.Save(first, anchor);
                MYDialog.Instance.Write("新锚点建立完成!\r\n待此文字位置与发送锚点的hololens看到的位置相同时\r\n锚点同步过程完成");

                IsImportAnchor = true;
                OperationBean op = new OperationBean();
                op.op = OperationBean.OpId.AnchorImported;
                SpectatorViewManager._instance.operationQueue.Enqueue(op);
            }
            else
            {
                Debug.Log("锚点导入失败!");
                OperationBean op = new OperationBean();
                op.op = OperationBean.OpId.AnchorImportFailed;
                SpectatorViewManager._instance.operationQueue.Enqueue(op);
            }
        }
コード例 #6
0
        /// <summary>
        /// Given a transfer batch, apply only the first anchor id to this object's gameObject.
        /// </summary>
        /// <param name="batch"></param>
        /// <returns>True if gameObject is anchored</returns>
        public bool ApplyAnchor(WorldAnchorTransferBatch batch, bool saveAchor)
        {
#if UNITY_WSA
            TargetGameObject = TargetGameObject == null ? gameObject : TargetGameObject;

            if (saveAchor)
            {
                _isAnchored = saveLoad.ApplySharedLocation(TargetGameObject, batch, worldAnchorStore);
            }
            else
            {
                ClearAnchor(false);
                var batchIds = batch.GetAllIds();
                if (batchIds.Length > 0)
                {
                    batch.LockObject(batchIds[0], TargetGameObject);
                    _isAnchored = true;
                }
                else
                {
                    _isAnchored = false;
                }
            }
#endif

            return(_isAnchored);
        }
コード例 #7
0
        /// <summary>
        /// Called when a remote anchor has been deserialized
        /// </summary>
        /// <param name="status"></param>
        /// <param name="wat"></param>
        private void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch wat)
        {
            if (status == SerializationCompletionReason.Succeeded)
            {
                if (SharingStage.Instance.ShowDetailedLogs)
                {
                    Debug.Log("Import complete");
                }

                if (wat.GetAllIds().Length > 0)
                {
                    string first = wat.GetAllIds()[0];

                    if (SharingStage.Instance.ShowDetailedLogs)
                    {
                        Debug.Log("Anchor name: " + first);
                    }

                    WorldAnchor anchor = wat.LockObject(first, gameObject);
                    anchorStore.Save(first, anchor);
                }

                AnchorLoadComplete();
            }
            else
            {
                Debug.LogError("Import failed");
                currentState = ImportExportState.DataReady;
            }
        }
コード例 #8
0
    /// <summary>
    /// Called when a remote anchor has been deserialized
    /// </summary>
    /// <param name="status">Tracks if the import worked</param>
    /// <param name="wat">The WorldAnchorTransferBatch that has the anchor information.</param>
    private void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch wat)
    {
        if (status == SerializationCompletionReason.Succeeded && wat.GetAllIds().Length > 0)
        {
            Debug.Log("Import complete");

            string first = wat.GetAllIds()[0];
            Debug.Log("Anchor name: " + first);

            WorldAnchor existingAnchor = objectToAnchor.GetComponent <WorldAnchor>();
            if (existingAnchor != null)
            {
                DestroyImmediate(existingAnchor);
            }

            WorldAnchor anchor = wat.LockObject(first, objectToAnchor);
            WorldAnchorManager.Instance.AnchorStore.Save(first, anchor);
        }
        else
        {
            // if we failed, we can simply try again.
            gotOne = true;
            Debug.Log("Import fail");
        }
    }
コード例 #9
0
        private void onImportCompleteForUnity(object transferBatchObject, object anchorTimeObject)
        {
            WorldAnchorTransferBatch transferBatch = (WorldAnchorTransferBatch)transferBatchObject;
            DateTime anchorTime = (DateTime)anchorTimeObject;


            //before we lock this, we remove the world anchor
            detachWorldAnchor();

            //locks it in place
            WorldAnchor wa = transferBatch.LockObject(gameObject.name, this.gameObject);

            anchorOrigin = AnchorOrigin.Server;


            //if (!wa.isLocated)
            //    wa.OnTrackingChanged += saveWhenLocated;
            //else
            //    //saves the importet anchor in the store
            WorldAnchorManager.Instance.SaveAnchor(this.gameObject);
            //transferBatch.Dispose();

            //if import complete, we take the time from information as current time
            latestAnchor = anchorTime;

            //reset
            //importInformation = default(ImportInformation);
        }
コード例 #10
0
    void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch anchorBatch)
    {
        if (status == SerializationCompletionReason.Succeeded)
        {
            if (anchorBatch.GetAllIds().Length > 0)
            {
                string first = anchorBatch.GetAllIds()[0];

                if (SharingStage.Instance.ShowDetailedLogs)
                {
                    Debug.Log("Anchor Manager: Sucessfully imported anchor " + first);
                }
                this.worldAnchor = anchorBatch.LockObject(first, gameObject);

                StatusTextDisplay.Instance.SetStatusText("synchronised");
            }

            base.FireCompleted(true);
        }
        else
        {
            StatusTextDisplay.Instance.SetStatusText("retrying synchronisation");

            Debug.LogError("Anchor Manager: Import failed");

            currentState = ImportState.DataDownloadedReadyForImport;
        }
    }
コード例 #11
0
    /// <summary>
    /// Called when a remote anchor has been deserialized.
    /// </summary>
    /// <param name="status"></param>
    /// <param name="wat"></param>
    void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch wat)
    {
        if (status == SerializationCompletionReason.Succeeded && wat.GetAllIds().Length > 0)
        {
            Debug.Log("Import complete");

            string first = wat.GetAllIds()[0];
            Debug.Log("Anchor name: " + first);
            WorldAnchor anchor = wat.LockObject(first, gameObject);

            anchorStore.Save(first, anchor);
            CurrentState = ImportExportState.Ready;
            GameObject.Find("HologramCollection").GetComponent <Holoscanner.RemoteMeshManager>().anchorSet = true;
            //GameObject.Find("orb").GetComponent<OrbPlacement>().setComponentsEnabled(true);
            //WorldAnchor a = GetComponent<WorldAnchor>();
            Debug.Log(gameObject.transform.position);
            Debug.Log(gameObject.transform.rotation);
            GameObject.Find("HologramCollection").GetComponent <Holoscanner.RemoteMeshManager>().worldtransform = gameObject.transform;
            //GameObject.Find("HologramCollection").GetComponent<Holoscanner.RemoteMeshManager>().SendTargetRequest();
        }
        else
        {
            Debug.Log("Import fail");
            CurrentState = ImportExportState.DataReady;
        }
    }
コード例 #12
0
        /// <summary>
        /// Called when a remote anchor has been deserialized
        /// </summary>
        /// <param name="status">Tracks if the import worked</param>
        /// <param name="wat">The WorldAnchorTransferBatch that has the anchor information.</param>
        private void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch wat)
        {
            if (status == SerializationCompletionReason.Succeeded && wat.GetAllIds().Length > 0)
            {
                Debug.Log("Import complete");

                string first = wat.GetAllIds()[0];
                Debug.Log("Anchor name: " + first);

                WorldAnchor existingAnchor = objectToAnchor.GetComponent <WorldAnchor>();
                if (existingAnchor != null)
                {
                    DestroyImmediate(existingAnchor);
                }

                WorldAnchor anchor = wat.LockObject(first, objectToAnchor);
                anchor.OnTrackingChanged += Anchor_OnTrackingChanged;
                Anchor_OnTrackingChanged(anchor, anchor.isLocated);

                ImportInProgress = false;
            }
            else
            {
                // if we failed, we can simply try again.
                gotOne = true;
                Debug.Log("Import fail");
            }
        }
コード例 #13
0
    // On successful load of WorldAnchors from disk, we iterate through the anchors
    // instantiate panels using the FixedPanel prefab for each anchor. These objects
    // are added to a dictionary which is then passed to the OnLoadCompleted method.
    private void InstantiateFixedPanels(WorldAnchorTransferBatch batch
                                        , GameObject panelObjectToAnchor)
    {
        Dictionary <String, GameObject> anchorIdToObject = new Dictionary <string, GameObject>();

        string[] ids = batch.GetAllIds();
        int      numAnchorsSkipped = 0;

        for (int i = 0; i < ids.Length; i++)
        {
            ProgressIndicator.Instance.SetProgress(0.60f + i / ids.Length * 0.35f);

            if (!IsValidPanelAnchorId(ids[i]))
            {
                Debug.LogFormat("Found anchor that does not correspond to a panel image target. Skipping load for \"{0}\".", ids[i]);
                numAnchorsSkipped++;
                continue;
            }

            GameObject panelToAnchor = GameObject.Instantiate(panelObjectToAnchor
                                                              , panelObjectToAnchor.transform.position
                                                              , panelObjectToAnchor.transform.rotation);
            panelToAnchor.transform.localScale = panelObjectLossyScale;

            if (panelToAnchor == null)
            {
                numAnchorsSkipped++;
                continue;
            }

            WorldAnchor anchor = batch.LockObject(ids[i], panelToAnchor);

            if (anchor == null)
            {
                numAnchorsSkipped++;
                Debug.LogFormat("WorldAnchor with id: {0} could not be locked!", ids[i]);
            }
            else
            {
                Debug.LogFormat("Loaded WorldAnchor for Panel with id: {0}", ids[i]);

                //Get WorldAnchorManager to take over tracking of anchor.
                WorldAnchorManager.Instance.AttachAnchor(panelToAnchor, ids[i]);

                anchorIdToObject.Add(ids[i], panelToAnchor);
            }
        }


        Dialog.Open(PrefabsManager.Instance.dialogPrefab
                    , DialogButtonType.OK
                    , "Success"
                    , string.Format("{0} WorldAnchors loaded and {1} WorldAnchors skipped!"
                                    , ids.Length - numAnchorsSkipped
                                    , numAnchorsSkipped));

        OnLoadAnchorsFromDiskCompleted(anchorIdToObject);
    }
コード例 #14
0
        /// <summary>
        /// Called when a remote anchor has been deserialized.
        /// </summary>
        /// <param name="status"></param>
        /// <param name="anchorBatch"></param>
        private void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch anchorBatch)
        {
            bool       successful     = status == SerializationCompletionReason.Succeeded;
            GameObject objectToAnchor = null;

            if (successful)
            {
                if (ShowDetailedLogs)
                {
                    Debug.LogFormat("[SharingWorldAnchorManager] Successfully imported \"{0}\" anchors.", anchorBatch.anchorCount.ToString());
                }

                if (AnchorDebugText != null)
                {
                    AnchorDebugText.text += string.Format("\nSuccessfully imported \"{0}\" anchors.", anchorBatch.anchorCount.ToString());
                }

                string[] anchorNames = anchorBatch.GetAllIds();

                for (var i = 0; i < anchorNames.Length; i++)
                {
                    if (AnchorGameObjectReferenceList.TryGetValue(anchorNames[i], out objectToAnchor))
                    {
                        AnchorStore.Save(anchorNames[i], anchorBatch.LockObject(anchorNames[i], objectToAnchor));
                    }
                    else
                    {
                        //TODO: Figure out how to get the GameObject reference from across the network.  For now it's best to use unique GameObject names.
                        Debug.LogWarning("[SharingWorldAnchorManager] Unable to import anchor!  We don't know which GameObject to anchor!");

                        if (AnchorDebugText != null)
                        {
                            AnchorDebugText.text += "\nUnable to import anchor!  We don\'t know which GameObject to anchor!";
                        }
                    }
                }
            }
            else
            {
                Debug.LogError("[SharingWorldAnchorManager] Import failed!");

                if (AnchorDebugText != null)
                {
                    AnchorDebugText.text += "\nImport failed!";
                }
            }

            if (AnchorDownloaded != null)
            {
                AnchorDownloaded(successful, objectToAnchor);
            }

            anchorBatch.Dispose();
            rawAnchorDownloadData = null;
            isImportingAnchors    = false;
        }
コード例 #15
0
    private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
    {
        if (completionReason != SerializationCompletionReason.Succeeded)
        {
            Debug.Log("Failed to import: " + completionReason.ToString());
            if (retryCount > 0)
            {
                retryCount--;
                indicator.GetComponent <MeshRenderer>().material.color = Color.cyan;
                WorldAnchorTransferBatch.ImportAsync(anchorData, OnImportComplete);
            }
            return;
        }

        GameObject rb = GameObject.Find("anchor1");

        if (rb != null)
        {
            foreach (string anid in deserializedTransferBatch.GetAllIds())
            {
                Debug.Log("the anchor id contained is: " + anid);
                if (anid == "anchor1")
                {
                    deserializedTransferBatch.LockObject(anid, anchorObject1);
                }
                else if (anid == "anchor2")
                {
                    deserializedTransferBatch.LockObject(anid, anchorObject2);
                }
            }
            indicator.GetComponent <MeshRenderer>().material.color = Color.green;
            TimeCost tc3 = new TimeCost("OFALL", Time.time.ToString() + "successfully locate the anchor");
            tCP.SocketSendByte(tc3);
            syncOrNot = true;
            //syncPlantInfor = true;
        }
        else
        {
            Debug.Log("Failed to find object for anchor id: " + spaceId);
            indicator.GetComponent <MeshRenderer>().material.color = Color.red;
        }
    }
コード例 #16
0
 private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
 {
     if (completionReason != SerializationCompletionReason.Succeeded)
     {
         //Import failed
         if (retryCount > 0)
         {
             retryCount--;
             WorldAnchorTransferBatch.ImportAsync(importedData, OnImportComplete);
         }
         return;
     }
     importedAnchor    = deserializedTransferBatch.LockObject(importAnchorName, gameObjectToSet);
     isRequestActive   = false;
     isRequestFinished = true;
 }
コード例 #17
0
    /// <summary>
    /// 锚点数据下载完成后,开始导入锚点数据
    /// </summary>
    /// <param name="completionReason"></param>
    /// <param name="deserializedTransferBatch"></param>
    private void ImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
    {
        if (completionReason == SerializationCompletionReason.Succeeded && deserializedTransferBatch.GetAllIds().Length > 0)
        {
            // 成功导入锚点
            // 获取第一个锚点名称
            bool     hasAnchorName = false;
            string[] anchorNames   = deserializedTransferBatch.GetAllIds();
            foreach (var an in anchorNames)
            {
                if (an == ExportingAnchorName)
                {
                    hasAnchorName = true;
                    break;
                }
            }

            if (!hasAnchorName)
            {
                currentState = ImportExportState.DataReady;
                return;
            }

            // 保存锚点到本地
            WorldAnchor anchor = deserializedTransferBatch.LockObject(ExportingAnchorName, gameObject);
            if (anchor.isLocated)
            {
                if (anchorStore.Save(ExportingAnchorName, anchor))
                {
                    currentState = ImportExportState.Ready;
                }
                else
                {
                    currentState = ImportExportState.DataReady;
                }
            }
            else
            {
                anchor.OnTrackingChanged += WorldAnchorForImport_OnTrackingChanged;
            }
        }
        else
        {
            // 未成功导入,则设置为DataReady,准备在下一帧再次导入,直到导入完成
            currentState = ImportExportState.DataReady;
        }
    }
コード例 #18
0
    private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
    {
        if (completionReason != SerializationCompletionReason.Succeeded)
        {
            Debug.Log("Failed to import: " + completionReason.ToString());
            debugText.text += "Failed to import: " + completionReason.ToString();
            if (retryCount > 0)
            {
                retryCount--;
                WorldAnchorTransferBatch.ImportAsync(importedWorldAnchor, OnImportComplete);
            }
            return;
        }

        debugText.text += "GameRootAnchor Imported!!! |";
        deserializedTransferBatch.LockObject("GameRootAnchor", WorldCenter);
    }
コード例 #19
0
    private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
    {
        if (completionReason == SerializationCompletionReason.Succeeded)
        {
            if (PlaySpaceManager.Instance.Floor.GetComponent <WorldAnchor>())
            {
                Destroy(PlaySpaceManager.Instance.Floor.GetComponent <WorldAnchor>());
            }

            deserializedTransferBatch.LockObject(PlaySpaceManager.Instance.Floor.name, PlaySpaceManager.Instance.Floor);

            State = States.Anchored;
        }
        else
        {
            Debug.LogErrorFormat("Failed to import Anchor; {0}", completionReason.ToString());
        }
    }
コード例 #20
0
 private void AnchorImportHandler(SerializationCompletionReason status, WorldAnchorTransferBatch watb)
 {
     if (status == SerializationCompletionReason.Succeeded)
     {
         // Load Imported Anchor
         Debug.Log("Anchor Import Handler");
         DeleteObjectAnchor();
         anchorStore.Delete(AnchorName);
         worldAnchor = watb.LockObject(AnchorName, anchoredObject);
         anchorStore.Save(AnchorName, worldAnchor);  // Force Save when sent as a located network anchor
         worldAnchor.OnTrackingChanged += WorldAnchor_OnTrackingChanged;
         CurrentState = ControlState.WaitingForAnchorLocation;
     }
     else
     {
         Debug.LogErrorFormat("AnchorControl: AnchorImportHander Error - {0}", status.ToString());
     }
 }
コード例 #21
0
    private void OnReceiveCompleted(SerializationCompletionReason reason, WorldAnchorTransferBatch batch)
    {
        if (reason != SerializationCompletionReason.Succeeded)
        {
            // Oops..
            return;
        }

        var allIds = batch.GetAllIds();

        foreach (var id in allIds)
        {
            GameObject newGuitar = Instantiate(objectToPlace);
            newGuitar.GetComponent <Identifier>().AnchorName = id;
            var anchor = batch.LockObject(id, newGuitar);

            _anchors.Add(id, anchor);
        }
    }
コード例 #22
0
    /// <summary>
    /// Called when a remote anchor has been deserialized
    /// </summary>
    /// <param name="status"></param>
    /// <param name="wat"></param>
    void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch wat)
    {
        if (status == SerializationCompletionReason.Succeeded && wat.GetAllIds().Length > 0)
        {
            DisplayUI.Instance.AppendText("Import complete");

            string first = wat.GetAllIds()[0];
            DisplayUI.Instance.AppendText("Anchor name: " + first);

            WorldAnchor anchor = wat.LockObject(first, gameObject);
            anchorStore.Save(first, anchor);
            currentState = ImportExportState.Ready;
        }
        else
        {
            DisplayUI.Instance.AppendText("Import fail");
            currentState = ImportExportState.DataReady;
        }
    }
    private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
    {
        Debug.LogFormat("OnImportComplete {0}", completionReason);

        importing = false;

        if (completionReason != SerializationCompletionReason.Succeeded)
        {
            if (importAttempts > 0)
            {
                importing = true;
                importAttempts--;
                WorldAnchorTransferBatch.ImportAsync(worldAnchorBuffer.ToArray(), OnImportComplete);
            }
            return;
        }

        worldAnchor = deserializedTransferBatch.LockObject(gameObject.name, gameObject);
    }
コード例 #24
0
    private void OnReceiveCompleted(SerializationCompletionReason reason, WorldAnchorTransferBatch batch)
    {
        if (reason != SerializationCompletionReason.Succeeded)
        {
            // Oops..
            Debug.Log("Failed to import: " + reason.ToString());
            return;
        }

        var allIds = batch.GetAllIds();

        foreach (var id in allIds)
        {
            GameObject myGameObject = GameObject.Find(id);
            var        anchor       = batch.LockObject(id, myGameObject);

            //_anchors.Add(id, anchor);
        }
    }
コード例 #25
0
    private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
    {
        if (completionReason != SerializationCompletionReason.Succeeded)
        {
            LogAsync("Failed to import: " + completionReason.ToString());
            return;
        }

        string[] ids = deserializedTransferBatch.GetAllIds();
        if (ids.Length > 0)
        {
            if (m_PointOfReference)
            {
                DestroyImmediate(m_PointOfReference);
            }

            m_PointOfReferenceCube.transform.position   = Vector3.zero;
            m_PointOfReferenceCube.transform.localScale = Vector3.one * 0.1f;

            m_PointOfReference = deserializedTransferBatch.LockObject(ids[0], m_PointOfReferenceCube);

            if (StatusText.Instance)
            {
                StatusText.Instance.SetText("Anchor Created");
            }
            Debug.Log("Anchor Created");

            if (store != null)
            {
                store.Delete(PointOfReferenceID);
            }

            StartCoroutine(SaveAnchor());

            if (StatusText.Instance)
            {
                StatusText.Instance.SetText("Anchor Saved to Store");
            }

            Debug.Log("Anchor Saved to Store");
        }
    }
コード例 #26
0
        private void ImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
        {
            importing = false;
            if (completionReason != SerializationCompletionReason.Succeeded)
            {
                Debug.LogError("Failed to import due to " + completionReason.ToString());
                ImportFromFile();
                return;
            }

            Debug.Log("Succesfully imported files.");


            string[] ids = deserializedTransferBatch.GetAllIds();
            for (int i = 0; i < ids.Length; ++i)
            {
                AnchorStore.Save(ids[i], deserializedTransferBatch.LockObject(ids[i], this.gameObject));
                Destroy(GetComponent <WorldAnchor>());
            }
        }
コード例 #27
0
    private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
    {
        if (completionReason != SerializationCompletionReason.Succeeded)
        {
            Debug.Log("Failed to import: " + completionReason.ToString());
            HololensConfigController.Instance.logMessage("Failed to import: " + completionReason.ToString());
            if (retryCount > 0)
            {
                retryCount--;
                WorldAnchorTransferBatch.ImportAsync(importedAnchorStoreData, OnImportComplete);
            }
            return;
        }

        string[] ids = deserializedTransferBatch.GetAllIds();
        if (ids != null)
        {
            HololensConfigController.Instance.logMessage("Imported: " + ids.Length + " WorldAnchors, now applying...");
            foreach (string id in ids)
            {
                GameObject obj = GameObject.Find(id);
                if (obj != null)
                {
                    deserializedTransferBatch.LockObject(id, obj);
                    HololensConfigController.Instance.logMessage("Imported world anchor for: " + id);
                    //transferBatch.LockObject(id, gameObject);
                }
                else
                {
                    Debug.Log("Failed to find object for anchor id: " + id);
                    HololensConfigController.Instance.logMessage("Failed to find object for anchor id: " + id);
                }
            }
        }
        else
        {
            HololensConfigController.Instance.logMessage("Imported 0 world anchors");
        }
    }
コード例 #28
0
    /// <summary>
    /// Called when a remote anchor has been deserialized.
    /// </summary>
    /// <param name="status"></param>
    /// <param name="wat"></param>
    void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch wat)
    {
        if (status == SerializationCompletionReason.Succeeded && wat.GetAllIds().Length > 0)
        {
            UIManager.Instance.LogMessage("Import complete");
            Debug.Log("Import complete");

            string first = wat.GetAllIds()[0];
            Debug.Log("Anchor name: " + first);

            WorldAnchor anchor = wat.LockObject(first, gameObject);
            anchorStore.Save(first, anchor);
            CurrentState = ImportExportState.Ready;
            AppStateManager.Instance.SetCurrentAppState(AppState.WaitingForGameStart);
        }
        else
        {
            UIManager.Instance.LogMessage("Import fail");
            Debug.Log("Import fail");
            CurrentState = ImportExportState.DataReady;
        }
    }
コード例 #29
0
    /// <summary>
    /// WorldAnchorのデシリアライズ完了 (onCompleted)
    /// </summary>
    private void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch anchorBatch)
    {
        Debug.Log("Import Complete.");

        if (status == SerializationCompletionReason.Succeeded)
        {
            if (anchorBatch.GetAllIds().Length > 0)
            {
                // デシリアライズしたアンカーの名前を取得
                string first = anchorBatch.GetAllIds()[0];
                m_importedAnchorID = first;
                Debug.Log("Anchor Manager: Sucessfully imported anchor " + first);

                // アンカーをGameObjectに取り付け現実空間に固定し、ローカルのストアに保存する
                WorldAnchor anchor = anchorBatch.LockObject(first, m_gameObject);
                m_anchorStore.Save(first, anchor);
            }
        }
        else
        {
            Debug.LogError("Anchor Manager: Import failed");
        }
    }
コード例 #30
0
 private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
 {
     if (completionReason != SerializationCompletionReason.Succeeded)
     {
         //Import failed
         if (retryCount > 0)
         {
             retryCount--;
             WorldAnchorTransferBatch.ImportAsync(importedData, OnImportComplete);
         }
         return;
     }
     DebugToServer.Log.Send("Setting world anchor...");
     string[] ids = deserializedTransferBatch.GetAllIds();
     foreach (string id in ids)
     {
         DebugToServer.Log.Send(id);
     }
     importedAnchor = deserializedTransferBatch.LockObject(importAnchorName, gameObjectToSet);
     DebugToServer.Log.Send("World anchor set for " + gameObjectToSet.name);
     isRequestActive   = false;
     isRequestFinished = true;
 }