Reputation: 291
I develop an unity application and I am working with azure spatial anchors. I found no possibility to delete a detected cloudAnchor. I tried this:
protected void OnCloudAnchorLocated(AnchorLocatedEventArgs args)
{
CloudSpatialAnchor nextCsa = args.Anchor;
...
if (nextCsa != null)
{
Debug.Log("BEFORE DELETE");
await CloudManager.DeleteAnchorAsync(nextCsa);
Debug.Log("AFTER DELETE");
}
}
I get this in the console:
StoreAndWatcherTrackedState::TryRemoveAsync for SpatialAnchor: 6b77de6e-d8ba-44ce-b7cc-1f1d09bcc7a5
And this error:
OnError - The specified spatial anchor is already associated with a different store
So I have three questions:
1. What is the meaning of the error?
2. Is it possible to delte detected anchors from azure?
3. If yes what is the correct approach?
Upvotes: 1
Views: 738
Reputation: 45
I cannot answer your first question. But I gave you my rough idea on how to delete anchor. I used List<CloudSpatialAnchor>
to save located anchor locally. Then you can create a button to delete all the located anchor.
void Start(){
...
List<CloudSpatialAnchor> nextCsa = new List<CloudSpatialAnchor>();
...
}
protected void OnCloudAnchorLocated(AnchorLocatedEventArgs args)
{
...
nextCsa.Add(args.Anchor);
...
}
public void DeleteAnchor(){
foreach(CloudSpatialAnchor anchor in nextCsa){
await this.CloudManager.DeleteAnchorAsync(anchor);
}
}
I hope this helps.
+++++++ EDIT +++++++
I might understand the solve for the first question.
The error you received might be connected to the ongoing Event on Cloud Session. You try to delete anchor before the LocateAnchorsCompleted
Event are completed. So, I suggest you to complete locating the anchor, stop the Watcher afterwards using
args.Watcher.Stop();
and delete the spatial anchor afterward.
Upvotes: 2