[iOS] Setting up Unity for ARKit development

Tutorial

·

Beginner

·

+10XP

·

30 mins

·

(303)

Unity Technologies

[iOS] Setting up Unity for ARKit development

In this tutorial, you will learn how to set up your unity project for ARKit development: from downloading the correct version of Unity to enabling the AR specific packages.

Languages available:

1. Overview

In this tutorial, you will learn how to set up your Unity project for AR development and add core AR components in your scene. This includes how to install the latest LTS version of Unity and appropriate build targets, add required AR packages, set up your scene hierarchy for AR development, and configure player settings optimized for handheld AR apps.

Note: This tutorial is for iOS development only. For the Android tutorials, go back to this tutorial in the AR Hello World Project.

2. Downloading Unity with Mobile Requirements

Install the correct version of Unity with the proper mobile build tools using the Unity Hub. Make sure you are using an iOS device with a Minimum iOS version of 11.0 with a macOS computer. Check supported devices here.

1. Download the Unity Hub. For more information, please click here for documentation or here for a video.

2. Install the Unity Version 2019.4.4f1 (LTS) (Figure 1)

Figure 1: Download 2019.4.4f1(LTS) on the Unity Hub

Figure 1: Download 2019.4.4f1(LTS) on the Unity Hub

3. Install the correct mobile development packages (Figure 2)

Figure 2: Check the correct boxes to download the mobile dev packages with your Unity version

Figure 2: Check the correct boxes to download the mobile dev packages with your Unity version

3. Creating a new 3D project

Use the Unity Hub to create a new project

1. Inside Unity Hub, click on Projects > New. If you have multiple Unity versions installed, make sure to click on the drop down arrow and click on 2019.4.4f1 (Figure 3)

Figure 3: Select the correct 2019.4.4f1 version for your new project

Figure 3: Select the correct 2019.4.4f1 version for your new project

2. Select the 3D template.

3. Enter a name for the Unity Project.

a. In this case, we will enter “Hello AR World”.

4. Select a location to save the Unity Project.

5. Click Create to launch your new project.

4. Change Build Settings

Configure build settings for your project to build your project for mobile devices

1. Inside your newly created project, let’s modify the build settings to target the iOS platform.

2. Click on File > Build Settings (Figure 4)

Figure 4: Drop down menu to access build settings.

Figure 4: Drop down menu to access build settings.

3. Click on Add Open Scenes button

4. Click on the iOS platform option

5. Click on the Switch Platform button (Figure 5)

Figure 5: Switch build targets to iOS

Figure 5: Switch build targets to iOS

6. You can close the Build Settings window and start installing the respective Unity Packages for our Hello AR World application.

5. Enable AR for your project and install required packages

Enable AR in your project using XR Plugin Management, and install the required packages for AR development via Project Settings

1. Click on Edit > Project Settings (Figure 6)

Figure 6: Drop down menu to access the Project Settings

Figure 6: Drop down menu to access the Project Settings

2. Inside the Project Settings window, find and select the XR Plugin Management tab

3. Click on the Install XR Plugin Management button (Figure 7)

Figure 7: XR Plugin Management in the Project Settings

Figure 7: XR Plugin Management in the Project Settings

4. Once you have installed the XR Plug-in Management, you can download packages to enable AR in various operating systems and providers(Figure 8)

Figure 8: XR Plug-in Management Screen

Figure 8: XR Plug-in Management Screen

5. Click the tab for iOS and check the box for ARKit (Figure 9)

Figure 9: ARKit checkbox for XR Plug-In Management

Figure 9: ARKit checkbox for XR Plug-In Management

6. Now, the correct packages should be installed.

7. Inside the Package Manager window, find and select AR Foundation

8. Install the 2019.4 verified package (Figure 10)

Figure 10: Download AR Foundation

Figure 10: Download AR Foundation

6. Configure project settings

Change project settings to maximize AR performance

1. Click on Edit > Project Settings

2. Inside the project settings window, click on the Player option. Most of the player settings will not be changed (Figure 11)

Figure 11: Change these player settings

Figure 11: Change these player settings

3. Change Company Name to a different name or leave it as is

4. The Product Name should already be named Hello AR World, but if it is not, you can change it to a different name.

5. Make sure you are in the iOS settings tab (iOS icon circled in red in the image above)

6. Click on the Other Settings section

7. Make sure the Auto Graphics API checkbox is checked

8. Uncheck the Multithreaded Rendering checkbox.

9. Enter a unique Bundle Identifier. Changing the DefaultCompany name is a good start (Figure 12)

  • NOTE: You may get an error about not having a unique Bundle Identifier when building to iOS. Be sure to enter a unique Bundle Identifier.
Figure 12: Change these player settings (multithreaded rendering, bundle identifier)

Figure 12: Change these player settings (multithreaded rendering, bundle identifier)

10. In the Camera Usage Description textbox enter, Enable to use AR Foundation or something similar.

11. Change the Target minimum iOS Version to 11.

12. Change the Architecture to ARM64 (Figure 13)

Figure 13: Change the Camera Usage Description/Minimum iOS ver/Architecture

Figure 13: Change the Camera Usage Description/Minimum iOS ver/Architecture

13. You can leave the rest of the settings as is

14. On the left-side of the Project Settings window, click XR

15. Click the Create button (Figure 14)

Figure 14: Create button under the XR Project Settings

Figure 14: Create button under the XR Project Settings

16. As soon as you click on the Create button, you will be prompted to save the ARKit Settings, click the Save button.

17. Lastly, change the requirement option from required to Optional (Figure 15)

Figure 15: Change the requirement

Figure 15: Change the requirement

7. Create AR Objects

Use AR packages to create AR objects for AR functionality in your project Scene

  • Note: These objects are not visible in the App Scene

1. In the Hierarchy, delete the Main Camera by right-clicking on the Main Camera > Delete (Figure 16)

Figure 16: Replace the Main Camera from the Inspector

Figure 16: Replace the Main Camera from the Inspector

2. Next, create an AR Session Origin object (Figure 17)

  • Right-click in the Hierarchy > XR > AR Session Origin

3. Create an AR Session object (Figure 17)

  • Right-click in the Hierarchy > XR > AR Session
Figure 17: XR drop down menu in the Inspector

Figure 17: XR drop down menu in the Inspector

4. In the Hierarchy, click on the drop-down arrow next to the AR Session Origin object

5. Click on AR Camera (Figure 18)

6. Under the Inspector, there is a Tag section. Click on the drop-down menu and select Main Camera.

Figure 18: Change the Tag for the AR Camera

Figure 18: Change the Tag for the AR Camera

8. Conclusion

In this tutorial, you have learned to set up a new Unity project with specific packages and settings that is configured for AR development. Next, you will need to configure your IDE such as Xcode to deploy to your device.

Complete this tutorial