Hello i have an issue to inizialize the cloudSession by code.
The idea is too attach this script to the AzureManager gameobject on the scene....for having one single session and many objects to anchor,
Does it make sense for you ?
However if the idea is fine for you, i have an error on the start session "Error on initialize the session"
Any idea? thanks Andrea
using Microsoft.Azure;
using Microsoft.Azure.SpatialAnchors;
using Microsoft.Azure.SpatialAnchors.Unity;
using Microsoft.MixedReality.OpenXR;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.XR.WSA;
using UnityEngine.XR.WSA.Input;
public class AnchorsManager : MonoBehaviour
{
/// <summary>
/// Local Anchor
/// </summary>
private GameObject localAnchor;
/// <summary>
/// AZURE settings AccountId
/// </summary>
private string AccountId = "00886172-b4....";
/// <summary>
/// AZURE settings AccountKey
/// </summary>
private string AccountKey = "xmQmM5zD3HNDZB0RAl6PsnSDVdm2l+.....";
/// <summary>Azure subscription 1
/// AZURE settings AccountDomain
/// </summary>
private string AccountDomain = "northeurope.mixedreality.azure.com";
/// <summary>
/// Azure session
/// </summary>
private CloudSpatialAnchorSession cloudSession;
void Start()
{
InitializeSession();
}
public void onMouseDown(GameObject localAnchor)
{
this.localAnchor = localAnchor;
this.cloudSession.Start();
}
/// <summary>
/// Inizialize the cloudSpatialAnchorSession.
/// </summary>
void InitializeSession()
{
try {
this.cloudSession = new CloudSpatialAnchorSession();
this.cloudSession.Configuration.AccountId = this.AccountId;
this.cloudSession.Configuration.AccountKey = this.AccountKey;
this.cloudSession.Configuration.AccountDomain = this.AccountDomain;
this.cloudSession.SessionUpdated += (sender, args) =>
{
if (args.Status.RecommendedForCreateProgress != 0)
{
// TODO CREATE ANCOR FUNCTION
}
};
}
catch (Exception ex) {
Debug.LogError("Error on initialize the session: " + ex.Message);
}
}
}
The error is
Error on initialize the session: AzureSpatialAnchors assembly:<unknown assembly> type:<unknown type> member:(null)
thanks for your help Andrea
For this one, it is likely due to the Unity conflicts in the version being used with the code above using both OpenXR and XR.WSA.
For the ASA SDK, we recommend to be using OpenXR + Unity 2020/2021 LTS versions of Unity which means removal of these references:
The sample that would recommend starting from is following if using HoloLens: https://learn.microsoft.com/en-us/azure/spatial-anchors/how-tos/setup-unity-project?tabs=xr-plugin-framework%2Cunity-2020%2Cunity-package-mixed-reality-feature-tool%2CExtraConfigurationsHoloLens