You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Import AzureSpacialAnchors asset into your script.
usingMicrosoft.Azure.SpatialAnchors;
Add the CloudSpatialAnchorSession and CloudSpatialAnchor member variables into your AzureSpatialAnchorsScript class:
/// <summary>/// Use the recognizer to detect air taps./// </summary>privateGestureRecognizerrecognizer;protectedCloudSpatialAnchorSessioncloudSpatialAnchorSession;/// <summary>/// The CloudSpatialAnchor that we either 1) placed and are saving or 2) just located./// </summary>protectedCloudSpatialAnchorcurrentCloudAnchor;/// <summary>/// True if we are 1) creating + saving an anchor or 2) looking for an anchor./// </summary>protectedbooltapExecuted=false;
Initialize Session:
/// <summary>/// Initializes a new CloudSpatialAnchorSession./// </summary>voidInitializeSession(){Debug.Log("ASA Info: Initializing a CloudSpatialAnchorSession.");if(string.IsNullOrEmpty(SpatialAnchorsAccountId)){Debug.LogError("No account id set.");return;}if(string.IsNullOrEmpty(SpatialAnchorsAccountKey)){Debug.LogError("No account key set.");return;}cloudSpatialAnchorSession=newCloudSpatialAnchorSession();cloudSpatialAnchorSession.Configuration.AccountId=SpatialAnchorsAccountId.Trim();cloudSpatialAnchorSession.Configuration.AccountKey=SpatialAnchorsAccountKey.Trim();cloudSpatialAnchorSession.LogLevel=SessionLogLevel.All;cloudSpatialAnchorSession.Error+=CloudSpatialAnchorSession_Error;cloudSpatialAnchorSession.OnLogDebug+=CloudSpatialAnchorSession_OnLogDebug;cloudSpatialAnchorSession.SessionUpdated+=CloudSpatialAnchorSession_SessionUpdated;cloudSpatialAnchorSession.Start();Debug.Log("ASA Info: Session was initialized.");}
Call the InitializeSession() method inside the Start() function:
// Start is called before the first frame updatevoidStart(){recognizer=newGestureRecognizer();recognizer.StartCapturingGestures();recognizer.SetRecognizableGestures(GestureSettings.Tap);recognizer.Tapped+=HandleTap;InitializeSession();}