/// <summary> /// When receiving a remote anchor, notify other components. Once of these compoents should apply the new anchor /// </summary> private void OnReceivedRemoteAnchor(NetworkAnchorPlayer sender, ImportedAnchorChangedArgs args) { if (args == null) { return; } Debug.LogFormat("[NetworkAnchor] Received a new anchor from a remote client. (anchorId: {0})", args.AnchorId); lastKnownAnchorId = args.AnchorId; if (ReceivedRemoteAnchorTransferBatch != null) { ReceivedRemoteAnchorTransferBatch(this, args.TransferBatch); } }
/// <summary> /// The final function called once a network anchor has been imported. /// </summary> private void ImportAnchorDataCompleted(WorldAnchorTransferBatch batch) { lock (ImportingAndExportingLock) { // Validate batch, and if an imported anchor is needed if (!ImportingAnchorSource.IsValid) { Debug.LogFormat("[NetworkAnchorManager] Imported anchor, but we're no longer wanting to import an anchor {0}", DebugInfo()); return; } if (batch == null || batch.anchorCount == 0) { Debug.LogFormat("[NetworkAnchorManager] Imported anchor, but ignoring since batch was empty. {0}", DebugInfo()); } // Make a new set of change args var newImportedAnchor = new ImportedAnchorChangedArgs(batch); // Make sure we've received the anchor we were expecting to load if (newImportedAnchor.AnchorId != ImportingAnchorSource.AnchorId) { Debug.LogFormat("[NetworkAnchorManager] Imported anchor, but ignoring since this anchor is no longer being imported. {0}", DebugInfo()); return; } // save the last recieve anchor data ImportedAnchor = newImportedAnchor; // no longer loading an anchor ImportingAnchorSource = SharedAnchorData.Empty; if (ImportedAnchorChanged != null) { ImportedAnchorChanged(this, ImportedAnchor); } } }
/// <summary> /// When receiving a remote anchor, notify other components. Once of these compoents should apply the new anchor /// </summary> private void NetworkAnchorManager_ImportedAnchorChanged(NetworkAnchorManager sender, ImportedAnchorChangedArgs args) { if (ImportedAnchorChanged != null) { ImportedAnchorChanged(this, args); } }