I am pretty new to using Azure Spatial Anchors with Unity, but I am following a tutorial on Microsoft’s documentation site for using Spatial Anchors. This particular one is directed towards using Hololens, but I am going through and, on my end, trying to configure it towards being used on iOS and Android. But I am getting tripped up at this particular part of the tutorial:
// Get the WorldAnchor from the CloudSpatialAnchor and use it to position the sphere. sphere.GetComponent<UnityEngine.XR.WSA.WorldAnchor>().SetNativeSpatialAnchorPtr(args.Anchor.LocalAnchor);
I am wanting to use an AR ReferencePoint instead of a WorldAnchor but I am having trouble translating the above code to what I need. Particularly the SetNativeSpatialAnchorPtr part. Any help would be great!
To get the position of located Azure Spatial Anchors without UnityEngine.XR.WSA and without WorldAnchors:
Finally in
Release v2.9.0 · Azure/azure-spatial-anchors-samples · GitHub
I found CloudSpatialAnchor.GetPose();
private void CloudSession_AnchorLocated(object sender, AnchorLocatedEventArgs anchorLocatedEventArgs)
{
OnSpatialAnchorFeedback.Invoke($"AnchorLocated Status : '{anchorLocatedEventArgs.Status}' {anchorLocatedEventArgs.Anchor.Identifier} ");
switch (anchorLocatedEventArgs.Status)
{
case LocateAnchorStatus.Located:
Pose anchorPose = Pose.identity;
anchorPose = anchorLocatedEventArgs.Anchor.GetPose();
SpawnOrMoveCurrentAnchoredObject(anchorPose.position, anchorPose.rotation);
break;
case LocateAnchorStatus.AlreadyTracked:
// This anchor has already been reported and is being tracked
break;
case LocateAnchorStatus.NotLocatedAnchorDoesNotExist:
// The anchor was deleted or never existed in the first place
// Drop it, or show UI to ask user to anchor the content anew
break;
case LocateAnchorStatus.NotLocated:
// The anchor hasn't been found given the location data
// The user might in the wrong location, or maybe more data will help
// Show UI to tell user to keep looking around
break;
}
}