Exemple #1
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;
        }
    }
        private void Update()
        {
#if WINDOWS_UWP
            if (HolographicSettings.IsDisplayOpaque)
            {
                return;
            }

            if (gotOne)
            {
                Debug.Log("importing");
                gotOne           = false;
                ImportInProgress = true;
                WorldAnchorTransferBatch.ImportAsync(anchorData, ImportComplete);
            }

            if (oldAnchorName != AnchorName && !createdAnchor)
            {
                Debug.LogFormat("New anchor name {0} => {1}", oldAnchorName, AnchorName);
                oldAnchorName = AnchorName;
                if (string.IsNullOrEmpty(AnchorName))
                {
                    Debug.Log("anchor is empty");
                    AnchorEstablished = false;
                }
                else if (!AttachToCachedAnchor(AnchorName))
                {
                    Debug.Log("requesting download of anchor data");
                    WaitForAnchor();
                }
            }
#else
            return;
#endif
        }
Exemple #3
0
    /// <summary>
    /// Exports the currently created anchor.
    /// </summary>
    void Export()
    {
        WorldAnchor anchor = GetComponent <WorldAnchor>();

        if (anchor == null)
        {
            DisplayUI.Instance.AppendText("We should have made an anchor by now...");
            return;
        }

        string guidString = Guid.NewGuid().ToString();

        exportingAnchorName = guidString;

        // Save the anchor to our local anchor store.
        if (anchorStore.Save(exportingAnchorName, anchor))
        {
            sharedAnchorInterface = new WorldAnchorTransferBatch();
            sharedAnchorInterface.AddWorldAnchor(guidString, anchor);
            WorldAnchorTransferBatch.ExportAsync(sharedAnchorInterface, WriteBuffer, ExportComplete);
        }
        else
        {
            DisplayUI.Instance.AppendText("This anchor didn't work, trying again");
            currentState = ImportExportState.InitialAnchorRequired;
        }
    }
Exemple #4
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;
            }
        }
Exemple #5
0
    private void ExportWorldAnchor()
    {
        WorldAnchorTransferBatch transferBatch = new WorldAnchorTransferBatch();

        transferBatch.AddWorldAnchor("GameRootAnchor", WorldCenter.GetComponent <WorldAnchor>());
        WorldAnchorTransferBatch.ExportAsync(transferBatch, OnExportDataAvailable, OnExportComplete);
    }
Exemple #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);
        }
    static async Task <bool> ImportWorldAnchorToGameObjectAsync(
        GameObject gameObject,
        byte[] worldAnchorBits)
    {
        var  completion = new TaskCompletionSource <bool>();
        bool worked     = false;

        WorldAnchorTransferBatch.ImportAsync(worldAnchorBits,
                                             (reason, batch) =>
        {
            if (reason == SerializationCompletionReason.Succeeded)
            {
                var anchorId = batch.GetAllIds().FirstOrDefault();

                if (!string.IsNullOrEmpty(anchorId))
                {
                    batch.LockObject(anchorId, gameObject);
                    worked = true;
                }
            }
            batch.Dispose();
            completion.SetResult(true);
        }
                                             );
        await completion.Task;

        return(worked);
    }
Exemple #8
0
 public void StartSyncSinglePlant(byte[] data, GameObject indicator1)
 {
     anchorData = data;
     indicator  = indicator1;
     indicator1.GetComponent <MeshRenderer>().material.color = Color.black;
     WorldAnchorTransferBatch.ImportAsync(data, OnImportComplete);
 }
    void TransferAnchor(string anchorName, WorldAnchor worldAnchor)
    {
        var batch = new WorldAnchorTransferBatch();

        batch.AddWorldAnchor(anchorName, worldAnchor);
        WorldAnchorTransferBatch.ExportAsync(batch, OnDataAvailable, OnDataExported);
    }
Exemple #10
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);
        }
Exemple #11
0
        private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
        {
            if (completionReason != SerializationCompletionReason.Succeeded)
            {
                Debug.Log("Failed to import: " + completionReason.ToString());
                if (retryCount > 0)
                {
                    retryCount--;
                    WorldAnchorTransferBatch.ImportAsync(importedData, OnImportComplete);
                }
                else
                {
                    cbImportFinish(false, "Import Anchor Failed after retry times.", null);
                    cbImportFinish = null;
                }
                return;
            }

            Debug.Log("Import success!");

            if (File.Exists(anchorFilePath + "/" + anchorFileName))
            {
                File.Delete(anchorFilePath + "/" + anchorFileName);
            }

            cbImportFinish(true, null, deserializedTransferBatch);
            cbImportFinish = null;
        }
Exemple #12
0
        private void ContinueDownload()
        {
            Debug.Log("Load data from file");
            // 读取文件
            try
            {
                importedData = File.ReadAllBytes(anchorFilePath + "/" + anchorFileName);
            }
            catch (Exception e)
            {
                Debug.Log(e);
                downloadErrorString = e.ToString();

                cbImportFinish(false, "Load file error! " + e, null);
                cbImportFinish = null;
                return;
            }

            Debug.Log("Download, data size=" + importedData.Length + " , Begin to Import!");
            if (importedData.Length != 0)
            {
                retryCount = 3;
                WorldAnchorTransferBatch.ImportAsync(importedData, OnImportComplete);
            }
            else
            {
                cbImportFinish(false, "Anchor data is wrong!", null);
                cbImportFinish = null;
            }
        }
    /// <summary>
    /// WorldAnchorをシリアライズしてストレージに保存します。
    /// </summary>
    public void ExportAnchor()
    {
        string guidString = Guid.NewGuid().ToString();

        m_exportingAnchorID = guidString;

        // ローカルのストアにアンカーを保存
        var worldAnchor = m_gameObject.GetComponent <WorldAnchor>();

        if (worldAnchor != null && m_anchorStore.Save(m_exportingAnchorID, worldAnchor))
        {
            // 保存成功時
            Debug.Log("Anchor Manager: Exporting anchor " + m_exportingAnchorID);

            // WorldAnchorTransferBatchにアンカーのシリアライズを委譲
            sharedAnchorInterface = new WorldAnchorTransferBatch();
            sharedAnchorInterface.AddWorldAnchor(guidString, worldAnchor);

            WorldAnchorTransferBatch.ExportAsync(sharedAnchorInterface, WriteBuffer, ExportComplete);
        }
        else
        {
            Debug.LogWarning("Anchor Manager: Failed to export anchor, trying again...");
        }
    }
Exemple #14
0
        /// <summary>
        /// Sets the world anchor at the origin from data if succeeded.
        /// </summary>
        public static void ShareOriginComplete(string clusterID, bool succeeded)
        {
            if (succeeded && clusterID != shareID && _shareData != null)
            {
                if (MixedRealityDisplay.currentDisplay.shareOrigin)
                {
                    WorldAnchorTransferBatch.ImportAsync(_shareData.ToArray(), (SerializationCompletionReason completionReason, WorldAnchorTransferBatch batch) => {
                        if (completionReason != SerializationCompletionReason.Succeeded)
                        {
                            return;
                        }

                        // Disable the origin finder if it exists
                        if (_originFinder != null)
                        {
                            _originFinder.Disable();
                            _originFinder = null;
                        }

                        // Create the world anchor
                        SetWorldAnchor(batch.LockObject(MixedRealityDisplay.currentDisplayConfig.id, worldAnchor == null ?
                                                        new GameObject("WorldAnchor") : worldAnchor.gameObject));
                    });
                }
            }

            _shareData = null;
        }
        public void ExportToFile(GameObject gameObjectToExport)
        {
            if (exporting)
            {
                Debug.LogWarning("Manager is currently exporting, please try again later.");
                return;
            }

            if (gameObjectToExport == null)
            {
                Debug.LogError("Invalid GameObject");
                return;
            }

            var exportAnchor = gameObjectToExport.GetComponent <WorldAnchor>();

            if (exportAnchor != null)
            {
                if (TransferBatch.anchorCount > 0)
                {
                    TransferBatch.Dispose();
                }

                TransferBatch.AddWorldAnchor(exportAnchor.name, exportAnchor);
                WorldAnchorTransferBatch.ExportAsync(TransferBatch, ExportData, ExportComplete);
                exporting = true;
            }
            else
            {
                Debug.LogError("Cannot get anchor while exporting");
            }
        }
    /// <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;
        }
    }
        private void Update()
        {
#if UNITY_WSA
#if UNITY_2017_2_OR_NEWER
            if (HolographicSettings.IsDisplayOpaque)
            {
                return;
            }
#else
            if (!VRDevice.isPresent)
            {
                return;
            }
#endif

            if (gotOne)
            {
                _ = ProgressIndicator.StartProgressIndicator("Importing anchor data...");
                Debug.Log("Importing");
                gotOne             = false;
                IsImportInProgress = true;
                WorldAnchorTransferBatch.ImportAsync(anchorData, ImportComplete);
            }
#endif
        }
Exemple #18
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;
     }
 }
Exemple #19
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);
        }
    }
Exemple #20
0
        /// <summary>
        /// If we are supposed to create the anchor for export, this is the function to call.
        /// </summary>
        public void CreateAnchor()
        {
            exportingAnchorBytes.Clear();
            GenericNetworkTransmitter.Instance.SetData(null);
            objectToAnchor = SharedCollection.Instance.gameObject;

            if (PlayerPrefs.HasKey(SavedAnchorKey) && AttachToCachedAnchor(PlayerPrefs.GetString(SavedAnchorKey)))
            {
                exportingAnchorName = PlayerPrefs.GetString(SavedAnchorKey);
                Debug.Log("found " + AnchorName + " again");
            }
            else
            {
                exportingAnchorName = Guid.NewGuid().ToString();
            }

            WorldAnchorTransferBatch watb = new WorldAnchorTransferBatch();
            WorldAnchor worldAnchor       = objectToAnchor.GetComponent <WorldAnchor>();

            if (worldAnchor == null)
            {
                worldAnchor = objectToAnchor.AddComponent <WorldAnchor>();
            }

            Debug.Log("exporting " + exportingAnchorName);
            watb.AddWorldAnchor(exportingAnchorName, worldAnchor);
            WorldAnchorTransferBatch.ExportAsync(watb, WriteBuffer, ExportComplete);
        }
Exemple #21
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);
            }
        }
Exemple #22
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");
        }
    }
    /// <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;
        }
    }
Exemple #24
0
        private void Update()
        {
            switch (currentState)
            {
            // If the local anchor store is initialized.
            case ImportExportState.AnchorStore_Initialized:
                if (sharingServiceReady)
                {
                    InitRoomApi();
                }
                break;

            case ImportExportState.RoomApiInitialized:
                StartAnchorProcess();
                break;

            case ImportExportState.DataReady:
                // DataReady is set when the anchor download completes.
                currentState = ImportExportState.Importing;
                WorldAnchorTransferBatch.ImportAsync(rawAnchorData, ImportComplete);
                break;

            case ImportExportState.InitialAnchorRequired:
                currentState = ImportExportState.CreatingInitialAnchor;
                CreateAnchorLocally();
                break;

            case ImportExportState.ReadyToExportInitialAnchor:
                // We've created an anchor locally and it is ready to export.
                currentState = ImportExportState.UploadingInitialAnchor;
                Export();
                break;
            }
        }
Exemple #25
0
        /// <summary>
        /// Exports the currently created anchor.
        /// </summary>
        private void Export()
        {
            string guidString = Guid.NewGuid().ToString();

            exportingAnchorName = guidString;

            // Save the anchor to our local anchor store.
            if (thisAnchor != null && anchorStore.Save(exportingAnchorName, thisAnchor))
            {
                if (SharingStage.Instance.ShowDetailedLogs)
                {
                    Debug.Log("Anchor Manager: Exporting anchor " + exportingAnchorName);
                }

                if (AnchorDebugText != null)
                {
                    AnchorDebugText.text += string.Format("\nExporting anchor {0}", exportingAnchorName);
                }

                sharedAnchorInterface = new WorldAnchorTransferBatch();
                sharedAnchorInterface.AddWorldAnchor(guidString, thisAnchor);
                WorldAnchorTransferBatch.ExportAsync(sharedAnchorInterface, WriteBuffer, ExportComplete);
            }
            else
            {
                Debug.LogWarning("Anchor Manager: Failed to export anchor, trying again...");

                if (AnchorDebugText != null)
                {
                    AnchorDebugText.text += string.Format("\nFailed to export anchor, trying again...");
                }

                currentState = ImportExportState.InitialAnchorRequired;
            }
        }
Exemple #26
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");
            }
        }
Exemple #27
0
        // Sets the origin and creates a world anchor
        private static WorldAnchor CreateWorldAnchor(Vector3 position, Quaternion rotation)
        {
            // Create world anchor
            GameObject anchorObject = new GameObject("Origin");

            anchorObject.transform.position = position;
            anchorObject.transform.rotation = rotation;

            WorldAnchor worldAnchor = anchorObject.AddComponent <WorldAnchor>();

#if !UNITY_EDITOR
            if (MixedRealityDisplay.currentDisplay.shareOrigin)
            {
                // Share the world anchor
                WorldAnchorTransferBatch transferBatch = new WorldAnchorTransferBatch();
                transferBatch.AddWorldAnchor(MixedRealityDisplay.currentDisplayConfig.id, worldAnchor);

                WorldAnchorTransferBatch.ExportAsync(transferBatch, (byte[] data) => {
                    RPCManager.CallOnMaster(UniSAConfig.current, NodeConfig.current.id, "ShareOriginData", Encoding.ASCII.GetString(data));
                },
                                                     (SerializationCompletionReason completionReason) => {
                    RPCManager.CallOnMaster(UniSAConfig.current, "ShareOriginComplete", NodeConfig.current.id,
                                            completionReason == SerializationCompletionReason.Succeeded);
                });
            }
#endif

            return(worldAnchor);
        }
Exemple #28
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;
        }
    }
Exemple #29
0
    void Update()
    {
#if UNITY_WSA && !UNITY_EDITOR
        if (SharingStage.Instance.IsConnected)
        {
            switch (currentState)
            {
            case ImportState.Start:
                ConnectToRoom();
                this.currentState = ImportState.ReadyToImport;
                break;

            case ImportState.ReadyToImport:
                MakeAnchorDataRequest();
                break;

            case ImportState.DataDownloadedReadyForImport:
                // DataReady is set when the anchor download completes.
                currentState = ImportState.Importing;
                StatusTextDisplay.Instance.SetStatusText("importing synchronisation data");

                WorldAnchorTransferBatch.ImportAsync(rawAnchorData, ImportComplete);
                break;
            }
        }
#endif
    }
        public WorldAnchorExport(WorldAnchorTransferBatch transferBatch, UnityAction <List <byte> > callbackWhenFinished)
        {
            this.transferBatch        = transferBatch;
            toExport                  = new List <byte>();
            this.callbackWhenFinished = callbackWhenFinished;

            WorldAnchorTransferBatch.ExportAsync(transferBatch, onExportDataAvailable, onExportCompleted);
        }