# UAndroidXRSpatialAnchorsComponent

`#include <AndroidXRSpatialAnchorsComponent.h>`

The anchor component that can be added to create, destroy, and persist an anchor.

<br />

## Summary

### Inheritance

Inherits from: `USceneComponent`

| ### Constructors and Destructors ||
|---|---|
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#uandroidxrspatialanchorscomponent()` ||

| ### Public attributes ||
|---|---|
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#anchorinfo {}` | `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorEntity#class_u_android_x_r_spatial_anchor_entity *` The associated anchor entity with this component. |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#onanchorpersistfailed {}` | `FAnchorPersistOperationFailedDelegate` The callback for when the persist operation associated with this component fails. |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#onanchorpersisted {}` | `FSpatialAnchorPersistedDelegate` The callback for when the anchor associated with this component is persisted. |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#onanchorunpersistfailed {}` | `FAnchorPersistOperationFailedDelegate` The callback for when the unpersist operation fails. |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#onanchorunpersisted {}` | `FSpatialAnchorPersistedDelegate` The callback for when the anchor associated with this component is unpersisted. |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#bupdatecomponenttransform {true}` | `bool` Whether to update the component transform with the tracked anchor's transform. |

| ### Public functions ||
|---|---|
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#beginplay() override` | `void` |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#createanchor()` | `bool` Create an anchor and associate it with this component. |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#destroyanchor()` | `bool` Destroys the anchor associated it with this component. |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#initialize(https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorEntity#class_u_android_x_r_spatial_anchor_entity *InAnchor)` | `void` Set the associated anchor entity for this component (for example, after loading persisted anchors) |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#isvalidanchor() const ` | `bool` Returns whether the component has an anchor associated with it. |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#persistanchor()` | `bool` Persist the anchor associated with this component. |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#tickcomponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override` | `void` |
| `https://developer.android.com/develop/xr/unreal/reference/class/UAndroidXRSpatialAnchorsComponent#unpersistanchor()` | `bool` Unpersist the anchor associated with this component. |

## Public attributes

### AnchorInfo

```
UAndroidXRSpatialAnchorEntity * AnchorInfo {}
```
The associated anchor entity with this component.

This can be set through Initialize or will be set by calling CreateAnchor

### OnAnchorPersistFailed

```
FAnchorPersistOperationFailedDelegate OnAnchorPersistFailed {}
```
The callback for when the persist operation associated with this component fails.

### OnAnchorPersisted

```
FSpatialAnchorPersistedDelegate OnAnchorPersisted {}
```
The callback for when the anchor associated with this component is persisted.

### OnAnchorUnpersistFailed

```
FAnchorPersistOperationFailedDelegate OnAnchorUnpersistFailed {}
```
The callback for when the unpersist operation fails.

### OnAnchorUnpersisted

```
FSpatialAnchorPersistedDelegate OnAnchorUnpersisted {}
```
The callback for when the anchor associated with this component is unpersisted.

### bUpdateComponentTransform

```
bool bUpdateComponentTransform {true}
```
Whether to update the component transform with the tracked anchor's transform.

## Public functions

### BeginPlay

```
void BeginPlay() override
```

### CreateAnchor

```
bool CreateAnchor()
```
Create an anchor and associate it with this component.

<br />

| Details ||
|---|---|
| **Returns** | Whether the anchor was created |

### DestroyAnchor

```
bool DestroyAnchor()
```
Destroys the anchor associated it with this component.

<br />

| Details ||
|---|---|
| **Returns** | Whether the anchor was destroyed |

### Initialize

```
void Initialize(
  UAndroidXRSpatialAnchorEntity *InAnchor
)
```
Set the associated anchor entity for this component (for example, after loading persisted anchors)

### IsValidAnchor

```
bool IsValidAnchor() const 
```
Returns whether the component has an anchor associated with it.

<br />

| Details ||
|---|---|
| **Returns** | Whether the component has an anchor associated with it |

### PersistAnchor

```
bool PersistAnchor()
```
Persist the anchor associated with this component.

### TickComponent

```
void TickComponent(
  float DeltaTime,
  ELevelTick TickType,
  FActorComponentTickFunction *ThisTickFunction
) override
```

### UAndroidXRSpatialAnchorsComponent

```
 UAndroidXRSpatialAnchorsComponent()
```

### UnpersistAnchor

```
bool UnpersistAnchor()
```
Unpersist the anchor associated with this component.