/// </inheritdoc> public void StartSession(object context, object arScene) { this.context = context as Context; this.arFragment = arScene as ArFragment; if (this.spatialAnchorsSession == null) { CloudServices.Initialize(this.context); } this.spatialAnchorsSession = new CloudSpatialAnchorSession(); this.spatialAnchorsSession.Configuration.AccountKey = Constants.SpatialAnchorsAccountKey; this.spatialAnchorsSession.Configuration.AccountId = Constants.SpatialAnchorsAccountId; this.spatialAnchorsSession.Session = this.arFragment.ArSceneView.Session; this.spatialAnchorsSession.AnchorLocated += this.OnAnchorLocated; this.spatialAnchorsSession.LocateAnchorsCompleted += this.OnLocateAnchorsCompleted; this.spatialAnchorsSession.SessionUpdated += this.SessionUpdated; this.spatialAnchorsSession.TokenRequired += SpatialAnchorsSession_TokenRequired; this.spatialAnchorsSession.Error += (sender, e) => { SessionErrorEvent eventArgs = e?.Args; if (eventArgs == null) { return; } var message = $"{eventArgs.ErrorCode}: {eventArgs.ErrorMessage}"; ShowMessage(this, message); }; this.spatialAnchorsSession.Start(); this.Status = SpatialAnchorStatus.Iddle; this.arFragment.TapArPlane += OnTapArPlane; }
private void SpatialAnchorsSession_Error(object sender, SessionErrorEventArgs e) { SessionErrorEvent eventArgs = e?.Args; if (eventArgs == null) { Debug.WriteLine("Azure Spatial Anchors reported an unspecified error."); return; } string message = $"{eventArgs.ErrorCode}: {eventArgs.ErrorMessage}"; Debug.WriteLine(message); this.OnSessionError?.Invoke(sender, eventArgs); }