Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

World Anchors not working?

Discussion in 'VR' started by Wallawocko, Oct 18, 2016.

  1. Wallawocko

    Wallawocko

    Joined:
    Nov 1, 2015
    Posts:
    25
    Hey everyone,

    I've created a blank project, importing the HolotoolKit-Unity, created a blank scene, and followed these instructions to the T
    https://developer.microsoft.com/en-...istence_in_unity#getting_the_worldanchorstore

    Problem is, my Async call NEVER finishes. If i put a debug statement in AnchorStoreReady() it never gets called at all.
    What is going on? I've used World Anchors before and never had this issue (prior versions of HTK).

    Am i missing something in the build settings or something? Literally empty project, with nothing in it

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.VR.WSA.Persistence;
    4. using UnityEngine.VR.WSA;
    5.  
    6.  
    7. public class CollaborationObjectManager : MonoBehaviour {
    8.  
    9.     private bool Placing;
    10.     public string ObjectAnchorStoreName = "test";
    11.  
    12.     /// <summary>
    13.     /// Keeps track of locally stored anchors.
    14.     /// </summary>
    15.     WorldAnchorStore anchorStore = null;
    16.  
    17.  
    18.     void AnchorStoreReady(WorldAnchorStore store)
    19.     {
    20.         Debug.Log ("NEVER GETS CALLED");
    21.         anchorStore = store;
    22.         Placing = true;
    23.  
    24.         Debug.Log("looking for " + ObjectAnchorStoreName);
    25.         string[] ids = anchorStore.GetAllIds();
    26.         for (int index = 0; index < ids.Length; index++)
    27.         {
    28.             Debug.Log(ids[index]);
    29.             if (ids[index] == ObjectAnchorStoreName)
    30.             {
    31.                 WorldAnchor wa = anchorStore.Load(ids[index], gameObject);
    32.                 Placing = false;
    33.                 break;
    34.             }
    35.         }
    36.     }
    37.  
    38.     // Use this for initialization
    39.     void Start () {
    40.         WorldAnchorStore.GetAsync(AnchorStoreReady);
    41.     }
    42.  
    43.     // Update is called once per frame
    44.     void Update () {
    45.  
    46.     }
    47. }
    48.  
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Hello,

    You can try renaming the anchorStore to 'store' and then in the AnchorStoreReady function use this.store = store. Maybe that might work for you.

    When looking at the link above that is the one thing different with this script compared to the examples.

    Thank you,
    Wesley
     
  3. Hodgson_SDAS

    Hodgson_SDAS

    Joined:
    Apr 30, 2015
    Posts:
    123
    Are you actually pushing this to a device?

    If you're in the Editor/Emulator .GetAsyc will never get called.
     
  4. Wallawocko

    Wallawocko

    Joined:
    Nov 1, 2015
    Posts:
    25
    Yeah Hodgson, that was the issue. I was trying to test it in unity before ever pushing it to the device. Thanks!