Skip to content

Commit 4f12add

Browse files
authored
Merge pull request #195861 from pamistel/pamistel_DeleteAnchorWithoutLocating
pamistel delete anchors without locating them
2 parents 8619431 + c56b6fa commit 4f12add

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

articles/spatial-anchors/how-tos/create-locate-anchors-unity.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,21 @@ Learn more about the [AnchorLocatedDelegate](/dotnet/api/microsoft.azure.spatial
295295

296296
Learn more about the [DeleteAnchorAsync](/dotnet/api/microsoft.azure.spatialanchors.cloudspatialanchorsession.deleteanchorasync) method.
297297

298+
### Delete anchor after locating (recommended)
298299
```csharp
299300
await this.cloudSession.DeleteAnchorAsync(cloudAnchor);
300301
// Perform any processing you may want when delete finishes
301302
```
302303

304+
### Delete anchor without locating
305+
If you are unable to locate an anchor but would still like to delete it you can use the ``GetAnchorPropertiesAsync`` API which takes an anchorId as input to get the ``CloudSpatialAnchor`` object. You can then pass this object into ``DeleteAnchorAsync`` to delete it.
306+
```csharp
307+
var anchor = await cloudSession.GetAnchorPropertiesAsync(@"anchorId");
308+
await this.cloudSession.DeleteAnchorAsync(anchor);
309+
```
310+
311+
312+
303313
[!INCLUDE [Stopping](../../../includes/spatial-anchors-create-locate-anchors-stopping.md)]
304314

305315
Learn more about the [Stop](/dotnet/api/microsoft.azure.spatialanchors.cloudspatialanchorsession.stop) method.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
## Delete anchors
22

3-
To delete a cloud spatial anchor, you use the `DeleteAnchor()` method. Deleting anchors when no longer used is a good practice to include early on in your development process and practices, to keep your Azure resources cleaned up.
3+
Deleting anchors when no longer used is a good practice to include early on in your development process and practices, to keep your Azure resources cleaned up.
4+

0 commit comments

Comments
 (0)