Setting up Unity for AR Development
In a previous article, I defined the various types of Extended Reality (XR). In it, I defined Augmented Reality (AR) as, “Augmented Reality (AR) places digital objects in the physical world. Usually the device will have some type of camera, (such as a smartphone), that gives a live feed with the digital objects overlaid on it. AR usually only uses UI elements to allow you to interact with the digital object. A famous example of this technology is Pokemon GO.”
In this article, I will describe the steps necessary to setup a project in Unity to create AR content.
I’m using Unity 2022.3.19 for this project. It is recommended that you use 2022.3 or later for AR projects. I created a 3D URP project and named it Magicbox-AR. (Note: If you plan to release your AR project for iOS, you must have access to a Mac for the final build. Windows computers cannot build a final product for iOS devices.)
Once the project is created, you need to add the AR Foundation package. This can be found under Window -> Package Manager. Change the Packages: In Project tab to Packages: Unity Registry. Then you can either scroll through the list or search for AR Foundation.
During the installation process, you will be informed that the new input system is being installed and that you must restart the editor to enable it.
The documentation for AR Foundation shows us that it allows us to use provider plug-ins for various types of devices such as Android, iOS, and OpenXR.
If you look at the Platform support section of the documentation, you can see that we now need to install ARCore — Android, ARKit — iOS, or OpenXR — HoloLens/Meta Quest. I’m developing this project for Android, so I’ll be installing the ARCore Package. You install this package exactly like you did AR Foundation.
We should have all of the packages installed that we need, so it’s time to make sure that the build settings are set properly. Go to File -> Build Settings and select the OS that you wish to build to. In my case, I’m selecting Android.
If your OS is grayed out, you will need to install the module first. In the example above, iOS is grayed out because I did not install that module when I installed the 2022.3.19 version of Unity. If I try to select it, it tells me that I need to install it using Unity Hub.
The final step in this setup is enabling the plug-in(s). Got to Edit -> Project Settings and then select XR Plug-in Management on the left side.
In the window on the right, you will see tabs for the various OSs that we can build to. I selected the Android tab and then selected Google ARCore. (Since I never installed the iOS module, I don’t have a tab for that on this example.)
You are now ready to start building an AR project in Unity.