Use cloud anchors to build AR experiences that Android and iOS users can share.
This guide assumes that you have already downloaded the ARCore SDK for Unity and imported it into a Unity project targeting iOS.
If not, see the Quickstart for iOS for installation and configuration instructions.
If you are new to working with anchors, see Working with Anchors for an introduction.
Use Cloud Anchors
Set up your development environment for working with cloud anchors and try out the sample app.
About cloud anchor ID sharing
The CloudAnchor sample app uses Unity's Networking feature for sharing cloud anchor IDs between devices on the same network.
You can use a different solution in your own apps.
Add an API Key
To use the ARCore Cloud Anchors API in your app, you'll need an API Key.
Obtain an API Key. See Setting up API keys in the Google Cloud Platform Console Help Center if you are new to working with API keys.
Enable the ARCore Cloud Anchor API for your Google Cloud Platform project.
Add your API key to your project:
- In Unity, go to Edit > Project Settings > ARCore
- Add your API key to the Cloud Services API Key field.
Open the sample scene
The CloudAnchor sample is included with the ARCore SDK for Unity.
- In the Unity Project window, you can find the CloudAnchor.unity sample in:
Assets > GoogleARCore > Examples > CloudAnchor > Scenes
Configure build and platform settings
Add the sample scene to your build:
Try out the sample app
Launch the app
Go to your Xcode output folder and open the
Unity-iPhone.xcworkspacefile in Xcode.
To avoid build errors, do not build or launch from the included
In Xcode, select the
Unity-iPhoneproject in the left pane, connect your phone, and launch the app.
Host and resolve cloud anchors
The sample app launches on your phone and starts detecting planes in front of your camera.
Tap a plane to anchor an Andy Android object on it.
Tap the HOST button to host the anchor.
A host request is sent to the Google Cloud Anchor service. The host request includes data representing the anchor's position relative to the visual features near it. A successful host request establishes a cloud anchor here and assigns it a cloud anchor ID.
The app displays a room code after the hosting request succeeds. You can use the code to access previously hosted cloud anchors for this room, using the same device or another device.
Tap RESOLVE and enter a previously returned room code to access hosted cloud anchors for this room.
A resolve request is sent to the Google Cloud Anchor service and, if successful, returns cloud anchors currently hosted in the room. The sample app uses the transforms of returned cloud anchors to render the Andy Android objects attached to them.