Adding AR Capabilities
Learn how to add AR capabilities to your cloud-connected Unity project.
Now that you are successfully able to stream 3D content into Unity and know how to make custom adjustments, it's time to add AR capabilities to your project.
Unity provides a framework purpose-built for AR development called AR Foundation. It allows you to build across multiple mobile and wearable AR devices, such as Android with ARCore and iOS with ARKit.
Before using AR Foundation, make sure that your iOS device is compatible with ARKit or that your Android device has ARCore or Google Play Services for AR installed.
Clone the open-source Unity + AR Foundation + echo3D example project on GitHub and open it in Unity.
Open the AR Foundation sample scene located in:
Assets > AR Foundation > Scenes > SimpleAR > SimpleAR
In the hierarchy click on the
AR Session Origingame object.
In the inspector view, look for the
Place on Planescript and set the
Placed Prefabto the echo3D prefab in the
Assets > echo3Dfolder.
Edit the echo3D prefab and set your API key through in the Inspector view.
You can test the connection to echo3D by pressing
Playto start the app on Unity.
Note that the
Gameview will show a black screen - that is expected as the
Gameview tries to access the mobile AR camera which doesn't exists when running on a desktop machine.
Switch to the
Sceneview and drag the echo3D prefab from
Assets > echo3Dinto the hierarchy.
If the API key was set correctly you should be able to see 3D assets from the echo3D console stream into Unity.
Stopping Unity from playing should reset everything.
You are now ready to build the AR app on a mobile device.
File > Build Settings...or press
Make sure to set your platform to (either Android, iOS, or Universal Windows Platform (UWP), etc.) by choosing the target platform and pressing the
Switch Platformbutton on the bottom right corner.
Verify that the
SimpleARscene is ticked in the
Scenes in Buildlist and click
Build And Run.
When the application is loaded on your mobile device you might be asked to approve camera access permission.
Move the phone around until a surface is detected.
Tap the screen to place the model on the surface.
The model will steam and render in front of you.
If the model is too big or too small, go back to the console and add metadata to affect its scale. After adding metadata the model should change automatically.
You did it! 🎉