Azure / azure-spatial-anchors-samples

Azure Spatial Anchors sample code
Other
293 stars 138 forks source link

How to get CloudSpatialAnchor? #391

Closed jelmerS2 closed 1 year ago

jelmerS2 commented 1 year ago

I want to update an anchor's AppProperties and for this I need a reference to the CloudSpatialAnchor. However, anchors in the scene only get a CloudNativeAnchor and ARAnchor component.

How do I get a reference to CloudSpatialAnchor from an earlier retrieved anchor?

Varnauld commented 1 year ago

Happy New Year @jelmerS2 Thank you for your question (tracking 42852602) - assigning to @darax !

darax commented 1 year ago

Hi @jelmerS2 In Unity SpatialAnchorManager provides access to the underlying CloudSpatialAnchorSession. CloudSpatialAnchorSession provides APIs to get and update an anchor without needing to locate it.

What I think you need to do is something like:

CloudSpatialAnchor spa = await CloudManager.Session.GetAnchorPropertiesAsync("YOUR-ANCHOR-GUID");

spa.AppProperties.Add("new", "entry");

await CloudManager.Session.UpdateAnchorPropertiesAsync(spa);

this method will also enable you to delete anchors without first locating them.

Varnauld commented 1 year ago

Hi @jelmerS2 - was this helpful for you? May I close this topic if so? Thank you for confirming

jelmerS2 commented 1 year ago

Yes thanks! You can close this one :)


From: Vanessa Arnauld @.> Sent: Saturday, February 18, 2023 3:24:00 AM To: Azure/azure-spatial-anchors-samples @.> Cc: VERHOOG Jelmer @.>; Mention @.> Subject: Re: [Azure/azure-spatial-anchors-samples] How to get CloudSpatialAnchor? (Issue #391)

Hi @jelmerS2https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FjelmerS2&data=05%7C01%7Cjelmer.verhoog%40soprasteria.com%7C4a688c87cb4a459b5ccd08db115732ba%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C638122838432928679%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=dMHxB0j9enaQaWGDFmZsafATWwgJ3F%2F71ZUwfifZOqw%3D&reserved=0 - was this helpful for you? May I close this topic if so? Thank you for confirming

— Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-spatial-anchors-samples%2Fissues%2F391%23issuecomment-1435455246&data=05%7C01%7Cjelmer.verhoog%40soprasteria.com%7C4a688c87cb4a459b5ccd08db115732ba%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C638122838432928679%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2MYnNQWoH8fGJx767MRfcO6IF9MkW9SvrGne3vlIb70%3D&reserved=0, or unsubscribehttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FALLOYGJUSXAH6IO5F3E2BNLWYAXEBANCNFSM6AAAAAATM36ENY&data=05%7C01%7Cjelmer.verhoog%40soprasteria.com%7C4a688c87cb4a459b5ccd08db115732ba%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C638122838432928679%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=aVxnpIbda9JI%2BcpMXUo%2F0hUSYg5K5tMtTOW6OEORSDk%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

C2 - Restricted use