protected async void OnEnable() { if (!TryGetComponent(out m_arAnchorManager) || !m_arAnchorManager.enabled || m_arAnchorManager.subsystem == null) { Debug.Log($"ARAnchorManager not enabled or available; sample anchor functionality will not be enabled."); return; } foreach (ARAnchor existingAnchor in m_arAnchorManager.trackables) { if (!m_anchors.Contains(existingAnchor)) { Debug.Log($"Anchor added from ARAnchorManager's trackables: {existingAnchor.trackableId}, OpenXR Handle: {existingAnchor.GetOpenXRHandle()}"); m_anchors.Add(existingAnchor); } } m_arAnchorManager.anchorsChanged += AnchorsChanged; m_anchorStore = await m_arAnchorManager.LoadAnchorStoreAsync(); if (m_anchorStore == null) { Debug.Log("XRAnchorStore not available, sample anchor persistence functionality will not be enabled."); return; } // Request all persisted anchors be loaded once the anchor store is loaded. foreach (string name in m_anchorStore.PersistedAnchorNames) { // When a persisted anchor is requested from the anchor store, LoadAnchor returns the TrackableId which // the anchor will use once it is loaded. To later recognize and recall the names of these anchors after // they have loaded, this dictionary stores the TrackableIds. TrackableId trackableId = m_anchorStore.LoadAnchor(name); m_incomingPersistedAnchors.Add(trackableId, name); } }