private void DestroySession() { if (this.cloudAnchorManager != null) { this.cloudAnchorManager.StopSession(); this.cloudAnchorManager = null; } this.StopWatcher(); this.ClearVisuals(); }
private void AnchorLookedUp(string anchorId) { Log.Debug("ASADemo", "anchor " + anchorId); this.anchorId = 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.anchorVisuals[cloudAnchorIdentifier] = foundVisual; } }); this.cloudAnchorManager.OnLocateAnchorsCompleted += (sender, args) => { this.currentStep = DemoStep.DemoScreenshotMode; this.RunOnUiThread(() => { this.textView.Text = "Anchor located! Grab A Screenshot!"; this.EnableCorrectUIControls(); }); }; this.cloudAnchorManager.StartSession(); AnchorLocateCriteria criteria = new AnchorLocateCriteria(); criteria.SetIdentifiers(new string[] { anchorId }); this.cloudAnchorManager.StartLocating(criteria); }