Exemple #1
0
    /// <summary>
    /// Begin import anchor data from source.
    /// </summary>
    private void ImportAnchorData(SharedAnchorData anchorSource)
    {
        if (HolographicSettings.IsDisplayOpaque)
        {
            Debug.LogFormat("[NetworkAnchorManager] Ignoring import anchor request, as this device doesn't support anchoring. {0} {1}", anchorSource.ToString(), DebugInfo());
            return;
        }

        if (!anchorSource.IsValid)
        {
            Debug.LogFormat("[NetworkAnchorManager] Ignoring anchor source since it's invalid. {0} {1}", anchorSource.ToString(), DebugInfo());
            return;
        }

        if (anchorSource.SourceIp == LocalAddress)
        {
            Debug.LogFormat("[NetworkAnchorManager] Ignoring anchor source since it originated from this player. {0} {1}", anchorSource.ToString(), DebugInfo());
            return;
        }

        Debug.LogFormat("[NetworkAnchorManager] Importing anchor. {0} {1}", anchorSource.ToString(), DebugInfo());

        LoadingAnchor = true;
        anchorTransmitter.RequestData(anchorSource.SourceIp);
    }
    /// <summary>
    /// Begin import anchor data from source.
    /// </summary>
    private bool ImportAnchorData(SharedAnchorData anchorSource)
    {
        lock (ImportingAndExportingLock)
        {
            if (HolographicSettings.IsDisplayOpaque)
            {
                Debug.LogFormat("[NetworkAnchorManager] Ignoring import anchor request, as this device doesn't support anchoring. {0} {1}", anchorSource.ToString(), DebugInfo());
                return(false);
            }

            if (!anchorSource.IsValid)
            {
                Debug.LogFormat("[NetworkAnchorManager] Ignoring import anchor request, since the anchor is invalid. {0} {1}", anchorSource.ToString(), DebugInfo());
                return(false);
            }

            if (anchorSource.SourceIp == LocalAddress)
            {
                Debug.LogFormat("[NetworkAnchorManager] Ignoring import anchor request, since it originated from this player. {0} {1}", anchorSource.ToString(), DebugInfo());
                return(false);
            }

            if (ImportedAnchor != null && anchorSource.AnchorId == ImportedAnchor.AnchorId)
            {
                Debug.LogFormat("[NetworkAnchorManager] IIgnoring import anchor request, since it's already imported. {0} {1}", anchorSource.ToString(), DebugInfo());
                return(false);
            }

            if (ImportingAnchorSource.IsValid && ImportingAnchorSource.AnchorId == anchorSource.AnchorId)
            {
                Debug.LogFormat("[NetworkAnchorManager] Ignoring import anchor request, since it's already being imported. {0} {1}", anchorSource.ToString(), DebugInfo());
                return(false);
            }

            Debug.LogFormat("[NetworkAnchorManager] Importing anchor. {0} {1}", anchorSource.ToString(), DebugInfo());

            // no longer exported an anchor
            ExportingAnchorSource = SharedAnchorData.Empty;

            // save anchor being imported
            ImportingAnchorSource = anchorSource;

            // begin requesting data
            anchorTransmitter.RequestData(ImportingAnchorSource.AnchorId, ImportingAnchorSource.SourceIp);

            return(true);
        }
    }