-1

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

Gelso77
  • 1,763
  • 6
  • 30
  • 47

1 Answers1

1

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:

   using UnityEngine.XR.WSA;
   using UnityEngine.XR.WSA.Input;

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

Nathan - MSFT
  • 331
  • 1
  • 7
  • hello, i can't see any example in the link above, actually i can find a lot of documentation but i can't find a good example or an update guideline, Have you achieved a worked example ? – Gelso77 Jan 12 '23 at 16:54
  • yes, the docs guide to set the OpenXR settings in Unity + show how to setup the project overall without the WSA plugin or classes. From the link I sent, the tutorial is beside the docs at top of page. Here is direct link to follow along the sample in Unity 2020.3.25 (or higher): https://learn.microsoft.com/en-us/azure/spatial-anchors/tutorials/tutorial-new-unity-hololens-app?source=recommendations&tabs=azure-portal – Nathan - MSFT Jan 17 '23 at 15:31