예제 #1
0
    /// <summary>
    /// Handle load and save persistence events. During these events attempt to share an anchor if the current
    /// conditions make sense for the given event.
    /// </summary>
    private void OnPersistenceEvent(AnchorPersistence source, PersistenceEventArgs args)
    {
        if (args == null)
        {
            return;
        }

        if (args.AnchorOwner != gameObject)
        {
            Debug.LogErrorFormat("[NetworkAnchor] Unexpected persistence event, anchor owner is not the expected game object (anchor id: {0})", args.AnchorId);
            return;
        }

        pendingPersistenceEventArgs = args;
        if (anchorPlayer == null)
        {
            Debug.LogErrorFormat("[NetworkAnchor] Unable to process persistence event without a local instance of the Network Anchor Player (anchor id: {0})", args.AnchorId);
            return;
        }

        if (pendingPersistenceEventArgs.Type == PersistenceEventType.Loaded)
        {
            anchorPlayer.DefaultNetworkAnchor(pendingPersistenceEventArgs.AnchorId, gameObject);
        }
        else if (pendingPersistenceEventArgs.Type == PersistenceEventType.Saved)
        {
            anchorPlayer.ShareNetworkAnchor(pendingPersistenceEventArgs.AnchorId, gameObject);
        }

        pendingPersistenceEventArgs = null;
    }
예제 #2
0
 /// <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;
     }
 }