private void CreateAnchorExceptionCompletion(string message) { this.textView.Text = message; this.currentStep = DemoStep.Start; this.cloudAnchorManager.StopSession(); this.cloudAnchorManager = null; this.EnableCorrectUIControls(); }
private void StartNewSession() { this.DestroySession(); this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session); this.cloudAnchorManager.OnAnchorLocated += this.OnAnchorLocated; this.cloudAnchorManager.OnLocateAnchorsCompleted += this.OnLocateAnchorsCompleted; this.cloudAnchorManager.OnSessionUpdated += this.OnSessionUpdated; this.cloudAnchorManager.StartSession(); }
private void DestroySession() { if (this.cloudAnchorManager != null) { this.cloudAnchorManager.StopSession(); this.cloudAnchorManager = null; } this.ClearVisuals(); }
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); }
private void AnchorPosted(string anchorNumber) { this.RunOnUiThread(() => { this.textView.Text = "Anchor Number: " + anchorNumber; this.currentStep = DemoStep.Start; this.cloudAnchorManager.StopSession(); this.cloudAnchorManager = null; this.ClearVisuals(); this.EnableCorrectUIControls(); }); }
public void OnCreateButtonClicked(object sender, EventArgs args) { this.textView.Text = "Scan your environment and place an anchor"; this.DestroySession(); this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session); this.cloudAnchorManager.OnSessionUpdated += (_, sessionUpdateArgs) => { SessionStatus status = sessionUpdateArgs.Status; if (this.currentStep == DemoStep.CreateAnchor) { float progress = status.RecommendedForCreateProgress; if (progress >= 1.0) { if (this.anchorVisuals.TryGetValue(string.Empty, out AnchorVisual visual)) { //Transition to saving... this.TransitionToSaving(visual); } else { this.feedbackText = "Tap somewhere to place an anchor."; } } else { this.feedbackText = $"Progress is {progress:0%}"; } } }; this.cloudAnchorManager.StartSession(); this.currentStep = DemoStep.CreateAnchor; this.EnableCorrectUIControls(); }