/// <summary> /// Attempts to attach to an anchor by anchorName in the local store.. /// </summary> /// <returns>True if it attached, false if it could not attach</returns> private bool AttachToCachedAnchor(string CachedAnchorName) { if (string.IsNullOrEmpty(CachedAnchorName)) { Debug.Log("Ignoring empty name"); return(false); } UnityEngine.XR.WSA.Persistence.WorldAnchorStore anchorStore = WorldAnchorManager.Instance.AnchorStore; Debug.Log("Looking for " + CachedAnchorName); string[] ids = anchorStore.GetAllIds(); for (int index = 0; index < ids.Length; index++) { if (ids[index] == CachedAnchorName) { Debug.Log("Using what we have"); anchorStore.Load(ids[index], objectToAnchor); AnchorEstablished = true; return(true); } else { Debug.Log(ids[index]); } } // Didn't find the anchor. return(false); }
/// <summary> /// Attempts to attach to an anchor by anchorName in the local store.. /// </summary> /// <returns>True if it attached, false if it could not attach</returns> private bool AttachToCachedAnchor(string anchorName) { if (SharingStage.Instance.ShowDetailedLogs) { Debug.Log("Looking for " + anchorName); } string[] ids = anchorStore.GetAllIds(); for (int index = 0; index < ids.Length; index++) { if (ids[index] == anchorName) { if (SharingStage.Instance.ShowDetailedLogs) { Debug.LogFormat("Attempting to load {0}...", anchorName); } UnityEngine.XR.WSA.WorldAnchor anchor = anchorStore.Load(ids[index], gameObject); if (anchor.isLocated) { AnchorLoadComplete(); } else { anchor.OnTrackingChanged += ImportExportAnchorManager_OnTrackingChanged_Attaching; currentState = ImportExportState.Ready; } return(true); } } // Didn't find the anchor. return(false); }