Beispiel #1
0
    private async void FindAzureAnchor(string[] idsToQuery)
    {

        if (cloudManager.Session == null)
        {
            // Creates a new session if one does not exist
            Debug.Log("\ncloudManager.CreateSessionAsync()");
            await cloudManager.CreateSessionAsync();
        }

        // Starts the session if not already started
        Debug.Log("\ncloudManager.StartSessionAsync()");
        await cloudManager.StartSessionAsync();

        // Notify AnchorFeedbackScript
        OnFindASAAnchor?.Invoke();

        // create a query criteria by anchor id
        Debug.Log($"Trying to finding anchors with anchor-id {idsToQuery}");
        anchorLocateCriteria = new AnchorLocateCriteria { Identifiers = idsToQuery };

        // query the cloud anchor
        // Start watching for Anchors
        if (cloudManager != null && cloudManager.Session != null)
        {
            Debug.Log("\ncurrentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria)");
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }

    }
Beispiel #2
0
    /// <summary>
    /// Callback function that is executed when an anchor is located.
    /// </summary>
    private void CloudSpatialAnchorSession_AnchorLocated(object sender, AnchorLocatedEventArgs args)
    {
        switch (args.Status)
        {
        case LocateAnchorStatus.Located:
            Debug.Log("ASA Info: Anchor located! Identifier: " + args.Identifier);
            UnityDispatcher.InvokeOnAppThread(() =>
            {
                // Create a green sphere.
                var worldAnchor = SharedWorldAnchor.Instance.gameObject.AddComponent <WorldAnchor>();

                // Get the WorldAnchor from the CloudSpatialAnchor and use it to position the sphere.
                worldAnchor.SetNativeSpatialAnchorPtr(args.Anchor.LocalAnchor);
            });
            break;

        case LocateAnchorStatus.AlreadyTracked:
            Debug.Log("ASA Info: Anchor already tracked. Identifier: " + args.Identifier);
            break;

        case LocateAnchorStatus.NotLocated:
            Debug.Log("ASA Info: Anchor not located. Identifier: " + args.Identifier);
            break;

        case LocateAnchorStatus.NotLocatedAnchorDoesNotExist:
            Debug.LogError("ASA Error: Anchor not located does not exist. Identifier: " + args.Identifier);
            break;
        }

        // Clear Anchor Watcher
        AnchorWatcher = null;
    }
Beispiel #3
0
    public async Task StartAzureSession()
    {
        startedAsa           = true;
        anchorLocateCriteria = new AnchorLocateCriteria();

        CloudManager.SessionUpdated         += CloudManager_SessionUpdated;
        CloudManager.AnchorLocated          += CloudManagerOnAnchorLocated;
        CloudManager.LocateAnchorsCompleted += CloudManager_LocateAnchorsCompleted;
        CloudManager.LogDebug += CloudManagerOnLogDebug;
        CloudManager.Error    += CloudManager_Error;

        await CloudManager.CreateSessionAsync();

        HttpWebRequest  request      = (HttpWebRequest)WebRequest.Create(ApiURL + "/api/AnchorsAPI"); //.Create(String.Format("http://api.openweathermap.org/data/2.5/weather?id={0}&APPID={1}", CityId, API_KEY));
        HttpWebResponse response     = (HttpWebResponse)request.GetResponse();
        StreamReader    reader       = new StreamReader(response.GetResponseStream());
        string          jsonResponse = reader.ReadToEnd();
        var             result       = JsonUtility.FromJson <Response <Anchor> >(jsonResponse);

        anchorLocateCriteria.Identifiers = result.data.Select(anchor => anchor.identifier).ToArray();

        await CloudManager.StartSessionAsync();

        if (currentWatcher != null)
        {
            currentWatcher.Stop();
            currentWatcher = null;
        }
        currentWatcher = CreateWatcher();
        if (currentWatcher == null)
        {
            Debug.Log("Either cloudmanager or session is null, should not be here!");
        }
    }
Beispiel #4
0
    /// <summary>
    /// Method to locate nearby anchors given a already located one
    /// </summary>
    /// <param name="anchor"> alredy located anchor </param>
    public void LocateNearByAnchors(CloudSpatialAnchor anchor)
    {
        // for locating nearby anchors
        SetGraphEnabled(true, true);
        // make sure it doesn't search for ID
        anchorLocateCriteria.Identifiers = new string[0];

        NearAnchorCriteria nearAnchorCriteria = new NearAnchorCriteria();

        nearAnchorCriteria.SourceAnchor     = anchor;
        nearAnchorCriteria.DistanceInMeters = findNearRadius;
        nearAnchorCriteria.MaxResultCount   = maxNumberOfNearAnchor;
        anchorLocateCriteria.NearAnchor     = nearAnchorCriteria;

        if ((cloudManager != null) && (cloudManager.Session != null))
        {
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
            Debug.Log("Watcher created");
            Debug.Log("Looking for Azure anchor... please wait...");
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }
    }
        private void OnDestroy() => StopAndCleanupSession(); // When this sample is destroyed, ensure the session is cleaned up.

        /// <summary>
        /// Start the session and begin searching for anchors previously saved.
        /// </summary>
        private async Task StartSessionAsync()
        {
            // CreateSessionAsync cannot be called during Start(), since the SpatialAnchorManager may not have Start()ed yet itself.
            // Instead, we ensure the session is created before we start it.
            if (!m_cloudSpatialAnchorManagerSessionCreated)
            {
                await m_cloudSpatialAnchorManager.CreateSessionAsync();

                m_cloudSpatialAnchorManagerSessionCreated = true;
            }

            if (m_cloudSpatialAnchorManager.IsSessionStarted)
            {
                Debug.LogWarning("Cannot start session; session already started.");
                return;
            }

            // Start the session
            Debug.Log("Starting session...");
            await m_cloudSpatialAnchorManager.StartSessionAsync();

            Debug.Log($"Session started! Air tap to create a local anchor.");

            // And create the watcher to look for any created anchors
            if (m_cloudSpatialAnchorIDs.Count > 0)
            {
                Debug.Log($"Creating watcher to look for {m_cloudSpatialAnchorIDs.Count} spatial anchors");
                AnchorLocateCriteria anchorLocateCriteria = new AnchorLocateCriteria();
                anchorLocateCriteria.Identifiers = m_cloudSpatialAnchorIDs.ToArray();
                m_cloudSpatialAnchorWatcher      = m_cloudSpatialAnchorManager.Session.CreateWatcher(anchorLocateCriteria);
                Debug.Log($"Watcher created!");
            }
        }
        /// <summary>
        /// Stop the session and cleanup any anchors created.
        /// </summary>
        private void StopAndCleanupSession()
        {
            // Clean up the sample scenario, destroying any anchors
            foreach (GameObject gameObject in m_foundOrCreatedAnchorObjects)
            {
                Destroy(gameObject);
            }
            m_foundOrCreatedAnchorObjects.Clear();

            // Stop the session
            if (!m_cloudSpatialAnchorManager.IsSessionStarted)
            {
                Debug.LogWarning("Cannot stop session; session has not started.");
                return;
            }

            Debug.Log("Stopping session...");
            m_cloudSpatialAnchorManager.StopSession();
            m_cloudSpatialAnchorManager.Session.Reset();

            // Stop the watcher, if it exists
            if (m_cloudSpatialAnchorWatcher != null)
            {
                m_cloudSpatialAnchorWatcher.Stop();
                m_cloudSpatialAnchorWatcher = null;
            }
            Debug.Log("Session stopped!");
        }
Beispiel #7
0
        /// <summary>
        /// Attempt to start watching for the current set anchor ids stored inside _pendingFinds.
        /// </summary>
        private async void TryWatching()
        {
            LogVerbose("TryWatching() called.");

            await ConnectSession();

            if (AnchorManager?.Session == null)
            {
                LogVerbose("There is no active anchor session.");
                return;
            }

            StopWatching();
            if (_pendingFinds.Count == 0)
            {
                LogVerbose("There no pending searches.");
                return;
            }

            AnchorLocateCriteria anchorLocateCriteria = new AnchorLocateCriteria()
            {
                Identifiers         = _pendingFinds.Keys.ToArray <string>(),
                RequestedCategories = AnchorDataCategory.Spatial,
                Strategy            = LocateStrategy.AnyStrategy
            };

            LogVerbose("Starting anchor searches.");
            _anchorWatcher = AnchorManager.Session.CreateWatcher(anchorLocateCriteria);
        }
Beispiel #8
0
        public void StopLocating()
        {
            CloudSpatialAnchorWatcher watcher = this.cloudSession.GetActiveWatchers().FirstOrDefault();

            // Only 1 active watcher at a time is permitted.
            watcher?.Stop();
        }
Beispiel #9
0
 private void StopWatcher()
 {
     if (watcher != null)
     {
         watcher.Stop();
         watcher = null;
     }
 }
        public void StopLocating()
        {
            CloudSpatialAnchorWatcher watcher = this.spatialAnchorsSession.ActiveWatchers.FirstOrDefault();

            // Only 1 active watcher at a time is permitted.
            watcher?.Stop();
            watcher?.Dispose();
        }
    //Start looking for specified anchors
    public void FindAzureAnchor(string AnchorIDtoFind)
    {
        DebugWindowMessaging.Clear(); DebugWindowMessaging.Clear();
        //Provide list of anchor IDs to locate
        SetUpAnchorIDsToLocate();

        //Start watching for Anchors
        currentWatcher = CloudManager.CreateWatcher();
        Debug.Log("Azure anchors found!");
    }
Beispiel #12
0
        /// <summary>
        ///     指定されたAnchorIdに対応するSpatial AnchorをAzure Spatial Anchorsサービスから取得します。
        /// </summary>
        /// <param name="azureAnchorIds"></param>
        public void FindAzureAnchorById(params string[] azureAnchorIds)
        {
            try
            {
                Debug.Log("\nAnchorModuleScript.FindAzureAnchor()");

                OutputLog("Trying to find Azure anchor");

                var anchorsToFind = new List <string>();

                if (azureAnchorIds != null && azureAnchorIds.Length > 0)
                {
                    anchorsToFind.AddRange(azureAnchorIds);
                }
                else
                {
                    OutputLog("Current Azure anchor ID is empty", LogType.Error);
                    return;
                }

                // Azure Spatial Anchorsを検索する条件を設定します。
                anchorLocateCriteria = new AnchorLocateCriteria();

                // 検索するAnchorIdのリストを設定します。
                anchorLocateCriteria.Identifiers = anchorsToFind.ToArray();

                // 一度取得したアンカー情報に対して再取得した場合にローカルの情報をキャッシュとして利用するかを設定します。
                // 今回はキャッシュをバイパスするため、毎回Azure Spatial Anchorsへ問い合わせが発生します。
                anchorLocateCriteria.BypassCache = true;

                // アンカーの探索を開始します。この処理は時間がかかるためAzure Spatial Anchorsでは
                // Watcherを生成し別スレッド上で非同期処理が実施されます。
                // Anchorの探索と配置が完了した情報から順次AnchorLocatedイベントが発生します。
                // 取得したSpatial Anchorの設置がすべて完了するとLocatedAnchorsCompleteイベントが発生します。
                if (cloudManager != null && cloudManager.Session != null)
                {
                    currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);

                    Debug.Log("Watcher created");
                    OutputLog("Looking for Azure anchor... please wait...");
                }
                else
                {
                    OutputLog("Attempt to create watcher failed, no session exists", LogType.Error);

                    currentWatcher = null;
                }
            }
            catch (Exception e)
            {
                Debug.Log(e);
                throw;
            }
        }
Beispiel #13
0
        /// <summary>
        ///     指定されたAnchorIdで登録されたAnchorを中心に他のアンカーが存在するか検索を実施します。
        /// </summary>
        /// <param name="anchorId">基準になるAnchorId</param>
        public void FindNearByAnchor(string anchorId)
        {
            try
            {
                anchorLocateCriteria.Identifiers = new string[0];
                Debug.Log("\nAnchorModuleScript.FindAzureAnchor()");
                OutputLog("Trying to find near by Azure anchor");

                // このクラスで管理している取得済みSpatial Anchorの一覧の中に指定のAnchorが存在するか確認します。
                if (!locatedAnchors.ContainsKey(anchorId))
                {
                    OutputLog($"Not found anchor.id:{anchorId}.", LogType.Error);
                    return;
                }

                // Azure Spatial Anchorsを検索する条件を設定します。
                // アンカー周辺を検索するためにはCriteriaにNearAnchorCriteriaのインスタンスを割り当てます。
                anchorLocateCriteria.NearAnchor = new NearAnchorCriteria();

                // 基点になるAnchorの情報を設定します。
                anchorLocateCriteria.NearAnchor.SourceAnchor = locatedAnchors[anchorId];

                // 探索範囲と、同時検出数を設定します。
                anchorLocateCriteria.NearAnchor.DistanceInMeters = distanceInMeters;
                anchorLocateCriteria.NearAnchor.MaxResultCount   = maxResultCount;

                // 探索時のルールを設定します。周辺探索にはAnyStrategyを設定します。
                anchorLocateCriteria.Strategy = LocateStrategy.AnyStrategy;

                Debug.Log(
                    $"Anchor locate criteria configured to Search Near by Azure anchor ID '{anchorLocateCriteria.NearAnchor.SourceAnchor.Identifier}'");

                // アンカーの探索を開始します。この処理は時間がかかるためAzure Spatial Anchorsでは
                // Watcherを生成し別スレッド上で非同期処理が実施されます。
                // Anchorの探索と配置が完了した情報から順次AnchorLocatedイベントが発生します。
                // 取得したSpatial Anchorの設置がすべて完了するとLocatedAnchorsCompleteイベントが発生します。
                if (cloudManager != null && cloudManager.Session != null)
                {
                    currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
                    Debug.Log("Watcher created");
                    OutputLog("Looking for Azure anchor... please wait...");
                }
                else
                {
                    OutputLog("Attempt to create watcher failed, no session exists", LogType.Error);
                    currentWatcher = null;
                }
            }
            catch (Exception e)
            {
                Debug.Log(e);
                throw;
            }
        }
Beispiel #14
0
    //Start looking for specified anchors
    public void FindAzureAnchor(string AnchorIDtoFind)
    {
        OnFindASAAnchor?.Invoke();

        Debug.Log("Looking for anchor...");
        //Provide list of anchor IDs to locate
        SetUpAnchorIDsToLocate();

        //Start watching for Anchors
        currentWatcher = CloudManager.CreateWatcher();
    }
Beispiel #15
0
        /// <summary>
        /// Stop the current anchor watcher.
        /// </summary>
        private void StopWatching()
        {
            LogVerbose("StopWatching() called.");

            if (_anchorWatcher != null)
            {
                LogVerbose("Stopping anchor searches.");
                _anchorWatcher.Stop();
                _anchorWatcher = null;
            }
        }
Beispiel #16
0
    /// <summary>
    /// Finds an ASA anchor with the given id and sets the transform of the given target gameobject to the anchor position.
    /// </summary>
    /// <param name="id">The identifier of the ASA anchor that is searched for.</param>
    /// <param name="targetGameObject">The gameobject that will be repositioned when an anchor is found.</param>
    public void FindAzureAnchor(string id, GameObject targetGameObject)
    {
        //Guards
        if (id == "" || id == null)
        {
            Debug.Log("The anchor id is not allowed to be null or an empty string. No anchor searched.");
            return;
        }
        if (targetGameObject == null)
        {
            Debug.Log("The target gameobject is not allowed to be null. No anchor searched.");
            return;
        }

        Debug.Log("\nAnchorModuleScript.FindAzureAnchor()");

        // Notify AnchorFeedbackScript
        OnFindASAAnchor?.Invoke();

        // Set up list of anchor IDs to locate
        List <GameObject> gameObjectsWithSameAnchor;

        if (objectAnchors.TryGetValue(id, out gameObjectsWithSameAnchor))
        {
            gameObjectsWithSameAnchor.Add(targetGameObject);
        }
        else
        {
            List <GameObject> gameObjectList = new List <GameObject>();
            gameObjectList.Add(targetGameObject);
            objectAnchors.Add(id, gameObjectList);
        }

        List <string> anchorsToFind = new List <string>();

        anchorsToFind.Add(id);

        anchorLocateCriteria.Identifiers = anchorsToFind.ToArray();
        Debug.Log($"Anchor locate criteria configured to look for Azure anchor with ID '{currentAzureAnchorID}'");

        // Start watching for Anchors
        if ((cloudManager != null) && (cloudManager.Session != null))
        {
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
            Debug.Log("Watcher created");
            Debug.Log("Looking for Azure anchor... please wait...");
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }
    }
Beispiel #17
0
    void OnDestroy()
    {
        if (cloudManager != null && cloudManager.Session != null)
        {
            cloudManager.DestroySession();
        }

        if (currentWatcher != null)
        {
            currentWatcher.Stop();
            currentWatcher = null;
        }
    }
Beispiel #18
0
    void OnDestroy()
    {
        if (CloudManager != null)
        {
            CloudManager.EnableProcessing = false;
        }

        if (currentWatcher != null)
        {
            currentWatcher.Stop();
            currentWatcher = null;
        }
    }
        public void StopLocating()
        {
            var watchers = spatialAnchorsSession.ActiveWatchers;

            if (watchers.Count == 0)
            {
                return;
            }

            // Only 1 watcher is at a time is currently permitted.
            CloudSpatialAnchorWatcher watcher = watchers[0];

            watcher.Stop();
        }
    public void FindAzureAnchor(string id = "")
    {
        trigger = false;

        Debug.Log("\nAnchorModuleScript.FindAzureAnchor()");

        SendTimeServer("ASA", Time.time.ToString() + "Start finding the anchor from Server");

        if (id != "")
        {
            currentAzureAnchorID = id;
        }

        // Notify AnchorFeedbackScript
        OnFindASAAnchor?.Invoke();

        // Set up list of anchor IDs to locate
        List<string> anchorsToFind = new List<string>();

        if (currentAzureAnchorID != "")
        {
            anchorsToFind.Add(currentAzureAnchorID);
        }
        else
        {
            Debug.Log("Current Azure anchor ID is empty");
            return;
        }

        anchorLocateCriteria.Identifiers = anchorsToFind.ToArray();
        Debug.Log($"Anchor locate criteria configured to look for Azure anchor with ID '{currentAzureAnchorID}'");

        // Start watching for Anchors
        if ((cloudManager != null) && (cloudManager.Session != null))
        {
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
            Debug.Log("Watcher created");
            Debug.Log("Looking for Azure anchor... please wait...");
            cloudManager.AnchorLocated += CloudManager_AnchorLocated;
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }
        trigger = true;
        Debug.Log("Successfully download anchor and attach" + Time.time.ToString());
        indicator.GetComponent<MeshRenderer>().material.color = Color.green;
    }
        /// <summary>
        /// Destroying the attached Behaviour will result in the game or Scene
        /// receiving OnDestroy.
        /// </summary>
        /// <remarks>OnDestroy will only be called on game objects that have previously been active.</remarks>
        public override void OnDestroy()
        {
            if (CloudManager != null)
            {
                CloudManager.EnableProcessing = false;
            }

            if (currentWatcher != null)
            {
                currentWatcher.Stop();
                currentWatcher = null;
            }

            CleanupSpawnedObjects();
        }
Beispiel #22
0
        private void LookForAnchorsNearDevice()
        {
            var locateCriteria = new AnchorLocateCriteria
            {
                NearDevice = new NearDeviceCriteria
                {
                    DistanceInMeters = 8.0f,
                    MaxResultCount   = 25
                }
            };

            nearDeviceWatcher = cloudSession.CreateWatcher(locateCriteria);

            UpdateMainStatusTitle("Looking for anchors near device...");
        }
Beispiel #23
0
        private void StartWatcher()
        {
            if (CloudAnchorManager.LocatingAnchors)
            {
                FragmentHelper.BackToPreviousFragment(Activity);
            }

            watcher = CloudAnchorManager.StartLocating(new AnchorLocateCriteria
            {
                NearDevice = new NearDeviceCriteria
                {
                    DistanceInMeters = 8.0f,
                    MaxResultCount   = 25
                }
            });
        }
Beispiel #24
0
        public void connectToSignalR()
        {
            Debug.Log("trying to connect to signalR");

            HubOptions options = new HubOptions();

            options.SkipNegotiation = false;

            Uri uri = new Uri("https://ar-sphere-server-2.azurewebsites.net/connect");

            connection = new HubConnection(uri, new JsonProtocol(new LitJsonEncoder()), options);

            connection.OnError += (connection, error) =>
            {
                Debug.Log(error);
            };

            connection.OnConnected += (connection) =>
            {
                Debug.Log("connected!!!");
            };


            connection.On("NewNearbyAnchor", async(dynamic anchor) => {
                Debug.Log("new nearby anchor!!!");

                newNearbyAnchors.Add(anchor);

                if (!anchorsToFind.Contains(anchor["id"]))
                {
                    idToModelMap.Add(anchor["id"], anchor["model"] == null ? "Default" : anchor["model"]["name"]);
                    anchorsToFind.Add(anchor["id"]);
                    CloudManager.StopSession();
                    SetAnchorIdsToLocate(anchorsToFind);

                    await CloudManager.StartSessionAsync()
                    .ContinueWith(state => {
                        SetGraphEnabled(true);
                        currentWatcher = CreateWatcher();
                    });
                }
            });

            connection.StartConnect();
        }
Beispiel #25
0
        /// <summary>
        /// Destroying the attached Behaviour will result in the game or Scene
        /// receiving OnDestroy.
        /// </summary>
        /// <remarks>OnDestroy will only be called on game objects that have previously been active.</remarks>
        public override void OnDestroy()
        {
            if (CloudManager != null)
            {
                CloudManager.StopSession();
            }

            if (currentWatcher != null)
            {
                currentWatcher.Stop();
                currentWatcher = null;
            }

            CleanupSpawnedObjects();

            // Pass to base for final cleanup
            base.OnDestroy();
        }
Beispiel #26
0
    IEnumerator GetAnchorIdFromCloud()
    {
        UnityWebRequest uwr = UnityWebRequest.Get(generalConfiguration.apiUrl_CloudAnchorId);

        yield return(uwr.SendWebRequest());

        if (uwr.isNetworkError)
        {
            appStateManager.currentOutputMessage = $"Failed retrieving last used anchor ID from cloud.";
        }
        else
        {
            appStateManager.currentOutputMessage = $"Retrieved last used anchor ID from cloud, OK.  Looking for anchor - move the device about...";
            currentAnchorId = uwr.downloadHandler.text.Trim();
            SetAnchorIdsToLocate();
            currentWatcher = CreateWatcher();
        }
    }
Beispiel #27
0
    /// <summary>
    /// Begins the anchor location procedure using the ASA Anchor Watchers
    /// </summary>
    /// <param name="anchorId">The ID of the anchor to locate.</param>
    public void LocateAnchor(string anchorId)
    {
        // Ignore if it is a fake anchor
        if (anchorId == FakeCloudSpatialAnchorId)
        {
            return;
        }

        if (AnchorWatcher != null)
        {
            Debug.LogError("ASA Info: A watcher is already running.");
            return;
        }

        AnchorLocateCriteria criteria = new AnchorLocateCriteria();

        criteria.Identifiers = new string[] { anchorId };
        AnchorWatcher        = CloudSpatialAnchorSession.CreateWatcher(criteria);
    }
Beispiel #28
0
        /// Destroying the attached Behaviour will result in the game or Scene
        /// receiving OnDestroy.
        /// <remarks>OnDestroy will only be called on game objects that have previously been active.</remarks>
        public /*override*/ void OnDestroy()
        {
            if (CloudManager != null)
            {
                CloudManager.StopSession();
            }

            if (currentWatcher != null)
            {
                currentWatcher.Stop();
                currentWatcher = null;
            }

            CleanupSpawnedObjects();

            // Pass to base for final cleanup
            // base.OnDestroy();
            UnityEngine.XR.WSA.Input.InteractionManager.InteractionSourcePressed -= InteractionManager_InteractionSourcePressed;
        }
Beispiel #29
0
    public void FindAzureAnchor(string id = "")
    {
        Debug.Log("\nAnchorModuleScript.FindAzureAnchor()");

        if (id != "")
        {
            currentAzureAnchorID = id;
        }

        // Notify AnchorFeedbackScript
        OnFindASAAnchor?.Invoke();

        // Set up list of anchor IDs to locate
        List <string> anchorsToFind = new List <string>();

        if (currentAzureAnchorID != "")
        {
            anchorsToFind.Add(currentAzureAnchorID);
        }
        else
        {
            Debug.Log("Current Azure anchor ID is empty");
            return;
        }

        anchorLocateCriteria.Identifiers = anchorsToFind.ToArray();
        Debug.Log($"Anchor locate criteria configured to look for Azure anchor with ID '{currentAzureAnchorID}'");

        // Start watching for Anchors
        if ((cloudManager != null) && (cloudManager.Session != null))
        {
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
            Debug.Log("Watcher created");
            Debug.Log("Looking for Azure anchor... please wait...");
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }
    }
Beispiel #30
0
    public void LocateNearByAnchors(CloudSpatialAnchor anchor)
    {
        NearAnchorCriteria nearAnchorCriteria = new NearAnchorCriteria();

        nearAnchorCriteria.SourceAnchor     = anchor;
        nearAnchorCriteria.DistanceInMeters = 10;
        nearAnchorCriteria.MaxResultCount   = 2; // max anchor to find
        anchorLocateCriteria.NearAnchor     = nearAnchorCriteria;

        if ((cloudManager != null) && (cloudManager.Session != null))
        {
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
            Debug.Log("Watcher created");
            Debug.Log("Looking for Azure anchor... please wait...");
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }
    }