/// <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); } }
/// <summary> /// On creation save this as the static instance. There should be only one manager. /// </summary> private void Awake() { DontDestroyOnLoad(gameObject); instance = this; this.InitializeLocalAddress(); this.InitializeAnchorTransmitterOnce(); }
/// <summary> /// When receiving a remote anchor, apply it to this game object. /// </summary> private void OnReceivedRemoteAnchor(NetworkAnchorManager sender, LastReceivedAnchorArgs args) { if (args != null && anchorPersistence != null) { anchorPersistence.ApplyAnchor(args.TransferBatch, true); pendingPersistenceEventArgs = null; } }
/// <summary> /// Check if we can inititialize the anchor manager usage. If we can, only do the initialization work once. Note /// that the anchor manager instance won't be ready at "Start". /// </summary> private void WhenReadyInitializeAnchorManagerOnce() { // Check if already initialized if (networkAnchorManager != null) { return; } // Check if can initialize networkAnchorManager = NetworkAnchorManager.Instance; if (networkAnchorManager == null) { return; } networkAnchorManager.LastReceivedAnchorChanged += OnReceivedRemoteAnchor; }
/// <summary> /// Check if we can inititialize the anchor manager usage. If we can, only do the initialization work once. Note /// that the anchor manager instance won't be ready at "Start". /// </summary> private void WhenReadyInitializeAnchorManagerOnce() { // Check if already initialized if (networkAnchorManager != null) { return; } // Check if can initialize networkAnchorManager = NetworkAnchorManager.Instance; if (networkAnchorManager == null) { return; } networkAnchorManager.ImportedAnchorChanged += NetworkAnchorManager_ImportedAnchorChanged; }