Categories
Work In Progress

Setting Up Unity AR Foundation 5.0 pre in Unity 2021 LTS

The fastest path to get going in Augmented Reality is using Unity’s AR Foundation which acts as a…. “gateway” of sorts to Google’s ARCore and Apple’s ARKit.

I want to use the simulation features of AR Foundation 5 (which is currently in pre-release) while remaining on Unity 2021 LTS. It is currently a bit challenging to do this. Typically to do this you would set up your Unity Package Manager to include Pre-release packages and this gets you access to the new scary and probably unstable stuff. But when I did this in Unity 2021, I still only got AR Foundation 4.2.3 packages ( cue the * sad trombone * 📯). There are two ways to get around this.

The first way is to go into your Unity project’s ../Packages/manifest.json file and add this line.

"com.unity.xr.arfoundation": "5.0.0-pre.12"

This will automatically go get the 5.0-pre.12 packages and you are good to go. Shout out to Dilmer Valecillos for mentioning this in the comments of his Unity AR Foundation Simulation Tools Are Here! video.

The second way to get the 5.0-pre.12 packages (plus a lot of cool samples) is to clone Unity’s AR Foundation Samples github repo. You will then open up this repo in your Unity Hub. Unity Hub will bark at you saying:

“This project was made in a different editor version. To open this project, please install or switch to Unity 2022.”

But you will have the option to choose another Editor version and you can pick your 2021 LTS installation. You will get a couple of “Are you really really sure?”-type messages. I said “yes” and so far I’m good.

Check inside ../Assets/Scenes/ARFoundationMenu for the Menu.unity file. This will launch a pushbutton grid-style menu with all the samples available. Note: Some buttons will be disabled based on your build platform. For example, Object tracking is not available on Android.