How to Update UI using AR Foundation in Unity ECS

This will take you about 20 minutes in prep time if you don't have Unity set-up, and 30 minutes in coding and debug time.

Click Here for DOTS Tutorial

Stop struggling with the limited documentation. Follow this step-by-step tutorial: "How to Update UI using AR Foundation in Unity ECS."

Full workflows and code to update UI using AR Foundation to dynamically update on-screen instructions

Click Here for DOTS Tutorial

This gitbook takes you through step-by-step full workflows and code to update UI using AR Foundation to dynamically update on-screen instructions. Once you've coded along and fully finished the "How To Update UI using AR Foundation" tutorial, you will be able to update UI using AR Foundation to dynamically update on-screen instructions.

Click Here for DOTS Tutorial

High-Level steps to Update UI using AR Foundation:

Number 01

Dynamically update the on-screen text based on platform type (AR or non-AR)

Number 02

Update logo images to SVG files

Number 03

Make updates to Panel Settings for the UI to be either more desktop or mobile-friendly

FAQ

What is AR Foundation in Unity ECS?

Unity's AR Foundation is an API that sits on top of all the hardware AR SDKs. When we ask for "pose" from AR Foundation, AR Foundation automatically translates that request to whatever appropriate implementation. Unity does not implement any of these functionalities itself, it just a translation layer. AR Foundation calls a platform-specific "plug-in" to get the necessary data from the hardware. So adding the "AR Foundation" package is not enough, we must also include specific packages for AR platforms we will be targeting. In our case it will be ARKit. It is important to note that not all AR Foundation functionalities are available for all plug-ins. For example, ARKit and ARCore both now provide access to a depth API. The HoloLens does not provide this data.

How does AR fit into the Technology Stack in Unity ECS?

Unity has a robust XR plugin framework. Unity has been working to improve their multi-platform offering, enabling direct integrations through a unified plugin framework. The resulting tech stack consists of an API that exposes common functionalities across their supported platforms in a frictionless way for creators while enabling XR hardware and software providers to develop their own Unity plugins. This architecture offers the following benefits: Multi-platform developer tools such as AR Foundation and the XR Interaction Toolkit Faster partner updates from supported plugins via the Unity Package Manager More platforms have access to an interface to leverage Unity’s XR rendering optimizations and developer tools [Source: Unity]

How does Moetsi approach AR in Unity ECS?

In MainScene we will run a check if we are an AR system. If we are an AR system, we will create an IsARPlayerComponent singleton. We will then use RequireSingletonForUpdate<IsARPlayerComponent> for our AR-specific systems. We will create a new InputSystem for AR, ARInputSystem, that takes in screen taps and translates them to "shoot" commands. We will also update our PlayerCommand to take in AR pose. So our ARInputSystem will be sending "shoot" data through screen taps and updated position through grabbing ARKit's provided "pose". AR Foundation is written using MonoBehaviours. So we will create and update an ARPlayerPoseComponent in an Update(). The MonoBehaviour will use the EntityManager to update our ARPlayerPoseComponent and our ARInputSystem will pull this data to add it to our PlayerCommand.

Haven’t begun learning Unity DOTS yet, and need to start at the very beginning?

If you haven't yet dipped your toes into learning Unity's new multithreaded Data-Oriented Technology Stack (DOTS), now is the time. You can start at the very beginning with Moetsi’s tutorial, which culminates in your very own deployable sample project. You’ll be guided by full workflows, code-alongs, videos, and GIFs along the way.

Get Started