/// <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> /// When the app starts grab the anchor store immediately. /// </summary> protected override void Awake() { base.Awake(); AnchorStore = null; UnityEngine.XR.WSA.Persistence.WorldAnchorStore.GetAsync(AnchorStoreReady); }
/// <summary> /// Callback function that contains the WorldAnchorStore object. /// </summary> /// <param name="anchorStore">The WorldAnchorStore to cache.</param> protected virtual void AnchorStoreReady(UnityEngine.XR.WSA.Persistence.WorldAnchorStore anchorStore) { AnchorStore = anchorStore; if (!PersistentAnchors) { AnchorStore.Clear(); } }
/// <summary> /// When the app starts grab the anchor store immediately. /// </summary> protected override void Awake() { base.Awake(); #if UNITY_EDITOR Debug.LogWarning("World Anchor Manager does not work in the editor. Anchor Store will never be ready."); #endif #if UNITY_EDITOR || UNITY_WSA AnchorStore = null; UnityEngine.XR.WSA.Persistence.WorldAnchorStore.GetAsync(AnchorStoreReady); #endif }
/// <summary> /// Callback function that contains the WorldAnchorStore object. /// </summary> /// <param name="anchorStore">The WorldAnchorStore to cache.</param> protected override void AnchorStoreReady(UnityEngine.XR.WSA.Persistence.WorldAnchorStore anchorStore) { AnchorStore = anchorStore; if (!SharingStage.Instance.KeepRoomAlive || !PersistentAnchors) { if (AnchorDebugText != null) { AnchorDebugText.text += "\nClearing Anchor Store..."; } anchorStore.Clear(); } }
/// <summary> /// Callback function that contains the WorldAnchorStore object. /// </summary> /// <param name="anchorStore">The WorldAnchorStore to cache.</param> private void AnchorStoreReady(UnityEngine.XR.WSA.Persistence.WorldAnchorStore anchorStore) { AnchorStore = anchorStore; }
void GotStore(UnityEngine.XR.WSA.Persistence.WorldAnchorStore newStore) { store = newStore; GettingStore = false; }
/// <summary> /// Called when the local anchor store is ready. /// </summary> /// <param name="store"></param> private void AnchorStoreReady(UnityEngine.XR.WSA.Persistence.WorldAnchorStore store) { anchorStore = store; currentState = ImportExportState.AnchorStore_Initialized; }
/// <summary> /// When the app starts grab the anchor store immediately. /// </summary> void Start() { AnchorStore = null; Debug.Log("Get Anchor Store."); UnityEngine.XR.WSA.Persistence.WorldAnchorStore.GetAsync(AnchorStoreReady); }
/// <summary> /// Callback function that contains the WorldAnchorStore object. /// </summary> /// <param name="anchorStore">The WorldAnchorStore to cache.</param> private void AnchorStoreReady(UnityEngine.XR.WSA.Persistence.WorldAnchorStore anchorStore) { Debug.Log("Anchor Store Ready."); AnchorStore = anchorStore; }
protected override void Awake() { base.Awake(); AnchorStore = null; }