コード例 #1
0
        /// <summary>
        /// Steps to show problem with XRAnchorStore.Clear()
        /// </summary>
        /// <param name="anchorStore">An empty XRAnchorStore</param>
        /// <param name="anchorTrackableId">TrackableId for an ARAnchor</param>
        private static void TestAnchorStore(XRAnchorStore anchorStore, TrackableId anchorTrackableId)
        {
            string anchorName = "Anchor0";

            // Add the anchor to the anchorStore. Since anchorStore is empty, this succeeds.
            anchorStore.TryPersistAnchor(anchorTrackableId, anchorName);

            // Add the anchor again. Since it is already in the anchorStore, this fails with error message emitted.
            // This is correct and expected.
            anchorStore.TryPersistAnchor(anchorTrackableId, anchorName);
            // [XR] [Mixed Reality OpenXR Anchor]: Could not persist anchor "Anchor0"; name already used in anchor store.

            // Clear the anchorStore.
            anchorStore.Clear();

            // It seems to have cleared everything, because the anchorStore.PersistedAnchorNames.Count == 0 now.
            // But attempting to persist Anchor0 again will still result in the same error.
            // INCORRECT HERE.
            anchorStore.TryPersistAnchor(anchorTrackableId, anchorName);
            // [XR] [Mixed Reality OpenXR Anchor]: Could not persist anchor "Anchor0"; name already used in anchor store.

            // Now Un-persist the anchor.
            anchorStore.UnpersistAnchor(anchorName);

            // Persisting it now seems to succeed (or at least generates no error message.)
            anchorStore.TryPersistAnchor(anchorTrackableId, anchorName);
        }
コード例 #2
0
 public void AnchorStoreClear()
 {
     m_anchorStore.Clear();
     // Change visual for every anchor in the scene
     foreach (ARAnchor anchor in m_anchors)
     {
         ChangeAnchorVisual(anchor, "", false);
     }
 }