private void HandleAnchorLocated(object sender, AnchorLocatedEventArgs args) { Debug.Log($"Anchor recognized as a possible Azure anchor"); if (args.Status == LocateAnchorStatus.Located || args.Status == LocateAnchorStatus.AlreadyTracked) { currentCloudAnchor = args.Anchor; AppDispatcher.Instance().Enqueue(() => { Debug.Log($"Azure anchor located successfully"); var indicator = Instantiate(anchorPositionPrefab); #if WINDOWS_UWP || UNITY_WSA indicator.gameObject.CreateNativeAnchor(); if (currentCloudAnchor == null) { return; } Debug.Log("Local anchor position successfully set to Azure anchor position"); indicator.GetComponent <UnityEngine.XR.WSA.WorldAnchor>().SetNativeSpatialAnchorPtr(currentCloudAnchor.LocalAnchor); #elif UNITY_ANDROID || UNITY_IOS Pose anchorPose = Pose.identity; anchorPose = currentCloudAnchor.GetPose(); Debug.Log($"Setting object to anchor pose with position '{anchorPose.position}' and rotation '{anchorPose.rotation}'"); indicator.transform.position = anchorPose.position; indicator.transform.rotation = anchorPose.rotation; // Create a native anchor at the location of the object in question indicator.gameObject.CreateNativeAnchor(); #endif indicator.Init(currentTrackedObject); anchorArrowGuide.SetTargetObject(indicator.transform); activeAnchors.Add(currentTrackedObject.SpatialAnchorId, indicator); // Notify subscribers OnFindAnchorSucceeded?.Invoke(this, EventArgs.Empty); currentWatcher?.Stop(); currentTrackedObject = null; }); } else { Debug.Log($"Attempt to locate Anchor with ID '{args.Identifier}' failed, locate anchor status was not 'Located' but '{args.Status}'"); } StopAzureSession(); }
private async void FindAsaAnchorEditor() { anchorCreationController.StartProgressIndicatorSession(); await Task.Delay(3000); var targetPosition = Camera.main.transform.position; targetPosition.z += 0.5f; var indicator = Instantiate(anchorPositionPrefab); indicator.transform.position = targetPosition; indicator.Init(currentTrackedObject); anchorArrowGuide.SetTargetObject(indicator.transform); // Notify subscribers activeAnchors.Add(currentTrackedObject.SpatialAnchorId, indicator); AppDispatcher.Instance().Enqueue(() => OnFindAnchorSucceeded?.Invoke(this, EventArgs.Empty)); currentTrackedObject = null; }