Exemple #1
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(UnityEngine.VR.WSA.Sharing.SerializationCompletionReason status, UnityEngine.VR.WSA.Sharing.WorldAnchorTransferBatch wat)
        {
            if (status == UnityEngine.VR.WSA.Sharing.SerializationCompletionReason.Succeeded && wat.GetAllIds().Length > 0)
            {
                Debug.Log("Import complete");

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

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

                UnityEngine.VR.WSA.WorldAnchor anchor = wat.LockObject(first, objectToAnchor);
                WorldAnchorManager.Instance.AnchorStore.Save(first, anchor);
                ImportInProgress  = false;
                AnchorEstablished = true;
            }
            else
            {
                // if we failed, we can simply try again.
                gotOne = true;
                Debug.Log("Import fail");
            }
        }
Exemple #2
0
 /// <summary>
 /// Called when serializing an anchor is complete.
 /// </summary>
 /// <param name="status">If the serialization succeeded.</param>
 private void ExportComplete(UnityEngine.VR.WSA.Sharing.SerializationCompletionReason status)
 {
     if (status == UnityEngine.VR.WSA.Sharing.SerializationCompletionReason.Succeeded && exportingAnchorBytes.Count > minTrustworthySerializedAnchorDataSize)
     {
         AnchorName = exportingAnchorName;
         anchorData = exportingAnchorBytes.ToArray();
         GenericNetworkTransmitter.Instance.SetData(anchorData);
         createdAnchor = true;
         Debug.Log("Anchor ready");
         GenericNetworkTransmitter.Instance.ConfigureAsServer();
         AnchorEstablished = true;
     }
     else
     {
         CreateAnchor();
     }
 }