Exemple #1
0
    private void HandleAnchorFound(string anchorId, AnchorPosition anchorPos)
    {
        anchorPos.Init(spatialAnchorsInQuery[anchorId]);
        anchorPos.AnchorConfirmed();
        if (!SceneAnchorPositions.Contains(anchorPos))
        {
            SceneAnchorPositions.Add(anchorPos);
            Debug.Log($"Add anchor position of '{anchorId}' to the scene");
        }
        else
        {
            Destroy(anchorPos);
        }

        currentAnchorPosition = anchorPos;


        Debug.Log($"Anchor '{spatialAnchorsInQuery[anchorId].Name}' have been found, removing from the query list ");
        spatialAnchorsInQuery.Remove(anchorId);


        if (spatialAnchorsInQuery.Count > 0)
        {
            Debug.Log($"continue finding '{spatialAnchorsInQuery.Count}' more spatial anchors... ... ...");
        }
        else
        {
            Debug.Log("successully found all spatial anchors queried");
            if (inNavigationMode)
            {
                StartCoroutine(GenerateTransitionLines());
                dialogController.OpenDialog("Ready to start the navigation", "Now we have successfully located both your selected origin and destination and are ready to start navigating. Do you want to start the navigation now?", "navigate");
                progressIndicatorRotatingOrbsGo.SetActive(false);
                CloseProgressIndicator(progressIndicatorRotatingOrbs);
                //ToggleIndicator(progressIndicatorRotatingOrbs);
            }
            else
            {
                // show indicator
                indicator.GetComponent <PositionIndicator>().SetTarget(currentAnchorPosition.transform);
                indicator.SetActive(true);
                // show dialog confirm whether wanting to create a new anchor
                dialogController.OpenDialog("Creating a new spatial anchor", "Do you want to create a new spatial anchor?", "create");
            }
            CanStopWatcher?.Invoke();
        }
    }
Exemple #2
0
    private async void HandleCreateAnchorSucceeded()
    {
        // change the color the currentAnchor to succeed
        currentAnchorPosition.AnchorConfirmed();

        // upload spatial anchor entity to azure table
        var uploadTableSuccess = await dataManager.UploadOrUpdate(currentAnchorPosition.SpatialAnchorObject);

        if (uploadTableSuccess)
        {
            Debug.Log($"Successful upload '{currentAnchorPosition.SpatialAnchorObject.SpatialAnchorId}' to cloud table");
        }
        else
        {
            Debug.Log($"Failed to upload '{currentAnchorPosition.SpatialAnchorObject.SpatialAnchorId}' to cloud table");
            CancelAnchorProfile();
            return;
        }

        if (previousAnchorPosition != null)
        {
            // upload spatial anchor entity to azure table
            currentEdge.ConnectedSpatialAnchorId = currentAnchorPosition.SpatialAnchorObject.SpatialAnchorId;
            currentEdge.Id     = currentEdge.Name + ',' + currentEdge.ConnectedName;
            currentEdge.RowKey = currentEdge.Id;
            // upload Edge entity to azure table
            uploadTableSuccess = await dataManager.UpdateAdjacentTable(currentEdge);

            if (uploadTableSuccess)
            {
                Debug.Log($"Successful upload '{currentEdge.Id}' to cloud table");
            }
            else
            {
                Debug.Log($"Failed to upload '{currentEdge.Id}' to cloud table");
                CancelAnchorProfile();
                // Notify AnchorFeedbackScript
                return;
            }
        }

        Debug.Log("Add current anchorPosition to dict");
        // add the currentAnchorPosition to the dictionary
        SceneAnchorPositions.Add(currentAnchorPosition);
        Debug.Log($"Currently added '{SceneAnchorPositions.Count}' anchors during this session");
        // add the currentSpatialAnchor to the dictionary
        AddSpatialAnchor(currentAnchorPosition.SpatialAnchorObject);
        // add edge
        CreateEdge(previousAnchorPosition.SpatialAnchorObject, currentAnchorPosition.SpatialAnchorObject, Vector3.Distance(previousAnchorPosition.transform.position, currentAnchorPosition.transform.position));

        // add entries to dropdown list
        Debug.Log("Add created anchor to dropdown list");
        spatialAnchorDropdown.options.Add(new TMP_Dropdown.OptionData()
        {
            text = currentAnchorPosition.SpatialAnchorObject.Name
        });
        originDropdown.options.Add(new TMP_Dropdown.OptionData()
        {
            text = currentAnchorPosition.SpatialAnchorObject.Name
        });
        destDropdown.options.Add(new TMP_Dropdown.OptionData()
        {
            text = currentAnchorPosition.SpatialAnchorObject.Name
        });
    }