private void AnchorLookedUp(string anchorId) { this.DestroySession(); this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session); this.cloudAnchorManager.OnAnchorLocated += (sender, args) => this.RunOnUiThread(() => { CloudSpatialAnchor anchor = args.Args.Anchor; LocateAnchorStatus status = args.Args.Status; if (status == LocateAnchorStatus.AlreadyTracked || status == LocateAnchorStatus.Located) { AnchorVisual foundVisual = new AnchorVisual(anchor.LocalAnchor) { CloudAnchor = anchor }; foundVisual.AnchorNode.SetParent(this.arFragment.ArSceneView.Scene); string cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier; foundVisual.SetColor(foundColor); foundVisual.Render(this.arFragment); this.textView.Text = foundVisual.CloudAnchor.AppProperties["Label"]; } }); this.cloudAnchorManager.StartSession(); AnchorLocateCriteria criteria = new AnchorLocateCriteria(); criteria.SetIdentifiers(new string[] { anchorId }); this.cloudAnchorManager.StartLocating(criteria); }
// Use this for initialization private void Start() { Debug.Log("Start() anchorLocateCriteria = new AnchorLocateCriteria();"); anchorLocateCriteria = new AnchorLocateCriteria(); //#if UNITY_IOS // arkitSession = UnityARSessionNativeInterface.GetARSessionNativeInterface(); // UnityARSessionNativeInterface.ARFrameUpdatedEvent += UnityARSessionNativeInterface_ARFrameUpdatedEvent; //#endif //#if UNITY_ANDROID // UnityAndroidHelper.Instance.DispatchUiThread(unityActivity => // { // // We should only run the java initialization once // if (!JavaInitialized) // { // using (AndroidJavaClass cloudServices = new AndroidJavaClass("com.microsoft.CloudServices")) // { // cloudServices.CallStatic("initialize", unityActivity); // JavaInitialized = true; // } // } // this.CreateNewCloudSession(); // }); //#else Debug.Log("Start() CreateNetCloudSession"); CreateNewCloudSession(); //#endif }
public void LocalizeAnchor() { DispatcherQueue.Enqueue(() => { if (_cloudSpatialAnchorSession == null) { Log("CloudSpatialAnchorSession was null. Weird.", Color.red); return; } else { // Initialize session fresh & clean CleanupObjects(); _cloudSpatialAnchorSession.Stop(); _cloudSpatialAnchorSession.Dispose(); _cloudSpatialAnchorSession = null; InitializeSession(); // Create a Watcher with anchor ID to locate the anchor that was created before AnchorLocateCriteria criteria = new AnchorLocateCriteria { Identifiers = new string[] { _currentCloudAnchorId } }; _cloudSpatialAnchorSession.CreateWatcher(criteria); Log($"Localizing anchor with {_cloudSpatialAnchorSession.GetActiveWatchers().Count} watchers.\r\nLook around to gather spatial data..."); } }); }
public CloudSpatialAnchorWatcher StartLocating(AnchorLocateCriteria locateCriteria) { // Only 1 active watcher at a time is permitted. this.StopLocating(); return(this.spatialAnchorsSession.CreateWatcher(locateCriteria)); }
/// <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); }
/// <summary> /// Start is called on the frame when a script is enabled just before any /// of the Update methods are called the first time. /// </summary> public override async void Start() { if (CloudManager == null) { Debug.Break(); Debug.Log($"{nameof(CloudManager)} reference has not been set. Make sure it has been added to the scene and wired up to {this.name}.\n"); return; } if (!SanityCheckAccessConfiguration()) { Debug.Log($"{nameof(SpatialAnchorManager.SpatialAnchorsAccountId)}, {nameof(SpatialAnchorManager.SpatialAnchorsAccountKey)} and {nameof(SpatialAnchorManager.SpatialAnchorsAccountDomain)} must be set on {nameof(SpatialAnchorManager)}\n"); } dispatchQueue = new ConcurrentQueue <Action>(); CloudManager.SessionUpdated += CloudManager_SessionUpdated; CloudManager.AnchorLocated += (sender, args) => { QueueOnUpdate(() => CloudManager_AnchorLocated(sender, args)); }; CloudManager.LocateAnchorsCompleted += CloudManager_LocateAnchorsCompleted; CloudManager.LogDebug += CloudManager_LogDebug; CloudManager.Error += CloudManager_Error; anchorLocateCriteria = new AnchorLocateCriteria(); base.Start(); }
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!"); } }
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; } }
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!"); } }
void Start() { // Get a reference to the SpatialAnchorManager component (must be on the same gameobject) if (UseOwnAnchorManager) { cloudManager = ASAManager; } else { //Add new Spatial Anchor Manager to the gameobject gameObject.AddComponent <SpatialAnchorManager>(); cloudManager = GetComponent <SpatialAnchorManager>(); cloudManager.AuthenticationMode = AuthenticationMode.ApiKey; cloudManager.SpatialAnchorsAccountId = ASAAccountId; cloudManager.SpatialAnchorsAccountKey = ASAAccountKey; cloudManager.SpatialAnchorsAccountDomain = ASAAccountDomain; } if (cloudManager == null) { Debug.Log("There is no Spatial Anchor Manager Component on the same gameobject as the anchor module one. Please add one."); } else { Debug.Log("CloudManager ist da"); } // Register for Azure Spatial Anchor events cloudManager.AnchorLocated += CloudManager_AnchorLocated; anchorLocateCriteria = new AnchorLocateCriteria(); }
// Use this for initialization private void Start() { anchorLocateCriteria = new AnchorLocateCriteria(); #if UNITY_IOS arkitSession = UnityARSessionNativeInterface.GetARSessionNativeInterface(); UnityARSessionNativeInterface.ARFrameUpdatedEvent += UnityARSessionNativeInterface_ARFrameUpdatedEvent; #endif #if UNITY_ANDROID UnityAndroidHelper.Instance.DispatchUiThread(unityActivity => { // We should only run the java initialization once if (!JavaInitialized) { using (AndroidJavaClass cloudServices = new AndroidJavaClass("com.microsoft.CloudServices")) { cloudServices.CallStatic("initialize", unityActivity); JavaInitialized = true; } } this.CreateNewCloudSession(); }); #else CreateNewCloudSession(); #endif }
// Start is called before the first frame update async void Start() { anchorExchanger.WatchKeys("https://<YOUR_NAME>.azurewebsites.net/api/anchors"); GetComponent <SpatialAnchorManager>().AnchorLocated += CloudAnchor_Located; anchorLocateCriteria = new AnchorLocateCriteria(); await Initialize(); }
/// </inheritdoc> public void StartLocatingAnchors(string[] anchors) { this.Mode = SpatialAnchorsMode.SearchAnchors; StopLocatingAnchors(); var criteria = new AnchorLocateCriteria(); criteria.SetIdentifiers(anchors); this.spatialAnchorsSession.CreateWatcher(criteria); }
/// <summary> /// Start is called on the frame when a script is enabled just before any /// of the Update methods are called the first time. /// </summary> public override void Start() { //feedbackBox = XRUXPicker.Instance.GetFeedbackText(); //feedbackBox = GameObject.Find("CreateAnchorMenuText").transform.GetComponent<UnityEngine.UI.Text>(); // Create a temporary reference to the current scene. Scene currentScene = SceneManager.GetActiveScene(); // Retrieve the name of this scene. string sceneName = currentScene.name; if (sceneName.Equals("NavigationListAndNavExecution")) { feedbackBox = GameObject.Find("CreateFlowText").transform.GetComponent <UnityEngine.UI.Text>(); } else if (sceneName.Equals("Challenge1MainMenu")) { feedbackBox = GameObject.Find("CreateAnchorMenuText").transform.GetComponent <UnityEngine.UI.Text>(); } if (feedbackBox == null) { Debug.Log($"{nameof(feedbackBox)} not found in scene by XRUXPicker."); Destroy(this); return; } if (CloudManager == null) { Debug.Break(); feedbackBox.text = $"{nameof(CloudManager)} reference has not been set. Make sure it has been added to the scene and wired up to {this.name}."; return; } if (!SanityCheckAccessConfiguration()) { feedbackBox.text = $"{nameof(SpatialAnchorManager.SpatialAnchorsAccountId)} and {nameof(SpatialAnchorManager.SpatialAnchorsAccountKey)} must be set on {nameof(SpatialAnchorManager)}"; } if (AnchoredObjectPrefab == null) { feedbackBox.text = "AnchoredObjectPrefab is null in script base"; return; } CloudManager.SessionUpdated += CloudManager_SessionUpdated; // The method this event is binded to is not implemented in base class or SharedScript CloudManager.AnchorLocated += CloudManager_AnchorLocated; CloudManager.LocateAnchorsCompleted += CloudManager_LocateAnchorsCompleted; CloudManager.LogDebug += CloudManager_LogDebug; CloudManager.Error += CloudManager_Error; anchorLocateCriteria = new AnchorLocateCriteria(); base.Start(); }
void Start() { // Get a reference to the SpatialAnchorManager component (must be on the same gameobject) cloudManager = GetComponent <SpatialAnchorManager>(); // Register for Azure Spatial Anchor events cloudManager.AnchorLocated += CloudManager_AnchorLocated; anchorLocateCriteria = new AnchorLocateCriteria(); }
private void AnchorLookedUp(string anchorId) { Log.Debug("ASADemo", "anchor " + anchorId); this.anchorId = anchorId; this.DestroySession(); bool anchorLocated = false; this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session); this.cloudAnchorManager.OnAnchorLocated += (sender, args) => this.RunOnUiThread(() => { CloudSpatialAnchor anchor = args.Anchor; LocateAnchorStatus status = args.Status; if (status == LocateAnchorStatus.AlreadyTracked || status == LocateAnchorStatus.Located) { anchorLocated = true; AnchorVisual foundVisual = new AnchorVisual(anchor.LocalAnchor) { CloudAnchor = anchor }; foundVisual.AnchorNode.SetParent(this.arFragment.ArSceneView.Scene); string cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier; foundVisual.SetColor(foundColor); foundVisual.AddToScene(this.arFragment); this.anchorVisuals[cloudAnchorIdentifier] = foundVisual; } }); this.cloudAnchorManager.OnLocateAnchorsCompleted += (sender, args) => { this.currentStep = DemoStep.Start; this.RunOnUiThread(() => { if (anchorLocated) { this.textView.Text = "Anchor located!"; } else { this.textView.Text = "Anchor was not located. Check the logs for errors and\\or create a new anchor and try again."; } this.EnableCorrectUIControls(); }); }; this.cloudAnchorManager.StartSession(); AnchorLocateCriteria criteria = new AnchorLocateCriteria(); criteria.SetIdentifiers(new string[] { anchorId }); this.cloudAnchorManager.StartLocating(criteria); }
/// <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; } }
public void LoadAzureSpatialAnchors() { // CloudSpatialAnchorセッションを初期化するための処理を実行 ASAInitializeSession(); Debug.Log("ASA Info: 保存したアンカーを検索します。"); // 保存したAnchorを検索するWatcherを生成する AnchorLocateCriteria criteria = new AnchorLocateCriteria(); criteria.Identifiers = new string[] { identifierEntity.Identifier }; cloudSpatialAnchorSession.CreateWatcher(criteria); Debug.Log("ASA Info: Watcherを生成しました。 ActiveなWatcherの数: " + cloudSpatialAnchorSession.GetActiveWatchers().Count); }
void Start() { // Get a reference to the SpatialAnchorManager component (must be on the same gameobject) cloudManager = GetComponent <SpatialAnchorManager>(); // Register for Azure Spatial Anchor events cloudManager.AnchorLocated += CloudManager_AnchorLocated; anchorLocateCriteria = new AnchorLocateCriteria(); coarseRelocalizationSettings = Resources.Load <CoarseRelocalizationSettings>("CoarseRelocalizationConfig"); }
/// <summary> /// Start is called on the frame when a script is enabled just before any /// of the Update methods are called the first time. /// </summary> public override void Start() { connectToSignalR(); if (XRUXPicker.Instance.getAnchorId() != null) { anchorId = XRUXPicker.Instance.getAnchorId(); } feedbackBox = XRUXPicker.Instance.GetFeedbackText(); LatitudeBox = XRUXPicker.Instance.getLatitudeBox(); LongitudeBox = XRUXPicker.Instance.getLongitudeBox(); initGps(); if (feedbackBox == null) { Debug.Log($"{nameof(feedbackBox)} not found in scene by XRUXPicker."); Destroy(this); return; } if (CloudManager == null) { Debug.Break(); feedbackBox.text = $"{nameof(CloudManager)} reference has not been set. Make sure it has been added to the scene and wired up to {this.name}."; return; } if (!SanityCheckAccessConfiguration()) { feedbackBox.text = $"{nameof(SpatialAnchorManager.SpatialAnchorsAccountId)} and {nameof(SpatialAnchorManager.SpatialAnchorsAccountKey)} must be set on {nameof(SpatialAnchorManager)}"; } if (DefaultPrefab == null) { feedbackBox.text = "CreationTarget must be set on the demo script."; return; } CloudManager.SessionUpdated += CloudManager_SessionUpdated; CloudManager.AnchorLocated += CloudManager_AnchorLocated; CloudManager.LocateAnchorsCompleted += CloudManager_LocateAnchorsCompleted; CloudManager.LogDebug += CloudManager_LogDebug; CloudManager.Error += CloudManager_Error; anchorLocateCriteria = new AnchorLocateCriteria(); base.Start(); }
//method to find anchors based on geolocation + wifi public void findAnchorsByLocation() { //set a neardevicecriteria to look for anchors within 5 meters //can return max of 25 anchors to be searching for at once time here NearDeviceCriteria nearDeviceCriteria = new NearDeviceCriteria(); nearDeviceCriteria.DistanceInMeters = 5; nearDeviceCriteria.MaxResultCount = 25; AnchorLocateCriteria anchorLocateCriteria = new AnchorLocateCriteria(); anchorLocateCriteria.NearDevice = nearDeviceCriteria; debugText.text = "Trying to find anchors by location"; spatialAnchorManager.Session.CreateWatcher(anchorLocateCriteria); }
/// <summary> /// Start is called on the frame when a script is enabled just before any /// of the Update methods are called the first time. /// </summary> public override void Start() { feedbackBox = XRUXPicker.Instance.GetFeedbackText(); CloudManager.SessionUpdated += CloudManager_SessionUpdated; CloudManager.AnchorLocated += CloudManager_AnchorLocated; CloudManager.LocateAnchorsCompleted += CloudManager_LocateAnchorsCompleted; CloudManager.LogDebug += CloudManager_LogDebug; CloudManager.Error += CloudManager_Error; anchorLocateCriteria = new AnchorLocateCriteria(); base.Start(); }
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..."); }
private async void LoadAnchorAsync() { AnchorLocateCriteria criteria = new AnchorLocateCriteria(); string anchorId = await storageService.GetAnchorId(); // Local anchor is the same as the last saved one. No need to reload it. if (currentlyLoadingAnchorId == anchorId || loadedAnchor != null && loadedAnchor.Identifier == anchorId) { return; } Debug.Log(DEBUG_FILTER + "we are going to load anchor with id: " + anchorId); currentlyLoadingAnchorId = anchorId; // Stop all other watchers. foreach (var w in cloudSession.GetActiveWatchers()) { w.Stop(); } criteria.Identifiers = new string[] { anchorId }; cloudSession.CreateWatcher(criteria); cloudSession.AnchorLocated += (object sender, AnchorLocatedEventArgs args) => { switch (args.Status) { case LocateAnchorStatus.Located: loadedAnchor = args.Anchor; // Run on UI thread. QueueOnUpdate(() => SpawnOrMoveCurrentAnchoredObject(loadedAnchor)); break; case LocateAnchorStatus.AlreadyTracked: Debug.Log(DEBUG_FILTER + "Anchor already tracked. Identifier: " + args.Identifier); loadedAnchor = args.Anchor; break; case LocateAnchorStatus.NotLocatedAnchorDoesNotExist: Debug.Log(DEBUG_FILTER + "Anchor not located. Identifier: " + args.Identifier); break; case LocateAnchorStatus.NotLocated: Debug.LogError("ASA Error: Anchor not located does not exist. Identifier: " + args.Identifier); break; } }; }
//specific lookup for known anchors public void FindCloudAnchors() { //set AnchorLocateCriteria to look for the IDs we have stored in cloudIDs list AnchorLocateCriteria anchorLocateCriteria = new AnchorLocateCriteria(); //anchorLocateCriteria.Identifiers = cloudIDs.ToArray(); anchorLocateCriteria.Identifiers = new string[] { "7259b41a-7860-49c2-acbb-1dbeba9801c1" }; debugText.text = "Trying to locate : " + anchorLocateCriteria.Identifiers.GetValue(0); //create a watcher with the criteria containing list of IDs //when a watcher fires, AnchorLocated event will fire spatialAnchorManager.Session.CreateWatcher(anchorLocateCriteria); }
private void OnDestroy() { enableProcessing = false; if (cloudSpatialAnchorSession != null) { cloudSpatialAnchorSession.Dispose(); cloudSpatialAnchorSession = null; } if (anchorLocateCriteria != null) { anchorLocateCriteria = null; } _instance = null; }
/// <summary> /// Start is called on the frame when a script is enabled just before any /// of the Update methods are called the first time. /// </summary> public virtual void Start() { feedbackBox = XRUXPicker.Instance.GetFeedbackText(); if (feedbackBox == null) { Debug.Log($"{nameof(feedbackBox)} not found in scene by XRUXPicker."); Destroy(this); return; } #if UNITY_ANDROID || UNITY_IOS arRaycastManager = FindObjectOfType <ARRaycastManager>(); if (arRaycastManager == null) { Debug.Log("Missing ARRaycastManager in scene"); } #endif if (CloudManager == null) { Debug.Break(); feedbackBox.text = $"{nameof(CloudManager)} reference has not been set. Make sure it has been added to the scene and wired up to {this.name}."; return; } if (!SanityCheckAccessConfiguration()) { feedbackBox.text = $"{nameof(SpatialAnchorManager.SpatialAnchorsAccountId)} and {nameof(SpatialAnchorManager.SpatialAnchorsAccountKey)} must be set on {nameof(SpatialAnchorManager)}"; } if (AnchoredObjectPrefab == null) { feedbackBox.text = "CreationTarget must be set on the demo script."; return; } CloudManager.SessionUpdated += CloudManager_SessionUpdated; CloudManager.AnchorLocated += CloudManager_AnchorLocated; CloudManager.LocateAnchorsCompleted += CloudManager_LocateAnchorsCompleted; CloudManager.LogDebug += CloudManager_LogDebug; CloudManager.Error += CloudManager_Error; anchorLocateCriteria = new AnchorLocateCriteria(); }
public void LookForNearbyAnchors() { AnchorLocateCriteria criteria = new AnchorLocateCriteria(); NearAnchorCriteria nearCriteria = new NearAnchorCriteria { DistanceInMeters = 5, SourceAnchor = this.anchorVisuals[this.targetId].cloudAnchor }; criteria.NearAnchor = nearCriteria; // Cannot run more than one watcher concurrently this.StopLocating(); this.cloudSession.CreateWatcher(criteria); this.UpdateMainStatusTitle("Locating Nearby Anchors ...."); }
private async void SetupCloudSessionAsync() { spatialAnchorManager.AnchorLocated += CloudManagerAnchorLocated; anchorLocateCriteria = new AnchorLocateCriteria(); if (spatialAnchorManager.Session == null) { await spatialAnchorManager.CreateSessionAsync(); } currentAnchorId = ""; currentCloudSpatialAnchor = null; await spatialAnchorManager.StartSessionAsync(); appStateManager.currentOutputMessage = $"Startup OK. Move camera around to find surfaces, onto which you can place scenery. Otherwise press 'Restore' to look for previously saved anchor."; appStateManager.currentCloudAnchorState = CloudAnchorStateEnum.ReadyToCreateLocalAnchor; }
// Use this for initialization private void Start() { anchorLocateCriteria = new AnchorLocateCriteria(); #if UNITY_IOS arkitSession = UnityARSessionNativeInterface.GetARSessionNativeInterface(); UnityARSessionNativeInterface.ARFrameUpdatedEvent += UnityARSessionNativeInterface_ARFrameUpdatedEvent; #elif UNITY_ANDROID UnityAndroidHelper.Instance.DispatchUiThread(unityActivity => { using (AndroidJavaClass cloudServices = new AndroidJavaClass("com.microsoft.CloudServices")) { cloudServices.CallStatic("initialize", unityActivity); } }); #endif StartCoroutine(CreateNewCloudSession()); }