# Build an AR app with the Unity template

The Unity integration connects 01Spatial absolute localization to AR Foundation. ARKit or ARCore provides smooth frame-to-frame tracking; 01Spatial aligns that local session with persistent map coordinates.

Prepare AR Foundation and the target platform plugin, a Ready Map Key or Project Key, an API Key, and a confirmed map Origin. Keep responsibilities separated:

```text
AR Session Origin
├── AR Camera             # updated only by AR Foundation
└── Map Root              # receives map-to-session alignment
    └── Map Content       # stored in map coordinates
```

Acquire a CPU image with `ARCameraManager.TryAcquireLatestCpuImage()`, camera intrinsics, and the AR Camera transform from the same update. Copy them before asynchronous encoding, release `XRCpuImage`, send the localization request, and accept only a trusted successful pose. Apply alignment to **Map Root**, never overwrite the AR Camera. Discard responses from a reset AR session.

See [Localization API & AR integration](/tutorials/localization/localization-api) for the request contract and matrices. Validate synchronized sampling, image-orientation handling, credential delivery, session reset, and recovery on both iOS and Android hardware.
