Augmented Reality (AR) allows people to interact meaningfully with the real world through digitally enhanced content. This book will help get you started developing your own AR applications using the Unity 3D game engine and the AR Foundation toolkit provided by Unity Technologies Inc. Using the techniques and lessons presented in this book, you will be able to create your own AR applications and games for a variety of target devices.

AR technology is now commonly available on mobile consumer devices—smartphones and tablets, both iOS (ARKit) and Android (ARCore), and a new generation of wearable smart glasses. In this book, I focus on instructing you on how to develop AR applications for mobile devices, but the techniques and projects can also be applied to wearables.

By the end of this book, you will be able to build and run your own AR applications that add layers of information to the real world, enabling interaction with real and virtual objects and innovatively engaging your users.

Who this book is for

If you want to develop your own AR applications, I recommend using Unity with AR Foundation as it is one of the most powerful and flexible platforms. Developers interested in creating AR projects can use this book to accelerate their progress on the learning curve and gain experience through a variety of fun and interesting projects. This book complements Unity's own documentation and other resources and provides practical advice and best practices that will have you up and running and productive quickly.

You do not need to be a Unity expert to use this book, but some familiarity will help you get started more quickly. If you are a beginner, I recommend you first run through one or two introductory tutorials found on Unity Learn ( It may also be helpful to have some experience developing for mobile devices (iOS and/or Android).

That said, I start from the very beginning, walking you along your learning curve slowly at first and then faster as you gain experience. And I provide plenty of links to external resources if you want to learn more and explore specific topics in more depth. Experienced readers can push past the instructions and explanations they already know.

What this book covers

Chapter 1, Setting Up for AR Development, after briefly defining AR, gets you set up for AR development, installing the Unity 3D game engine and the AR Foundation toolkit, and ensuring your system is ready to develop for Android (ARCore) and/or iOS (ARKit) mobile devices.

Chapter 2, Your First AR Scene, jumps right into building and running AR scenes, starting with examples provided in the AR Foundation samples project from Unity, and then moving on to building your own simple scene from scratch, learning about ARSession components, prefabs, and a little bit of C# coding too.

Chapter 3, Improving the Developer Workflow, teaches you about troubleshooting, debugging, remote testing, and Unity MARS, which can make your development workflow more efficient.

Chapter 4, Creating an AR User Framework, sees you develop a framework for building AR applications that manages user interaction modes, user interface panels, and AR onboarding graphics, which we will save as a template for reuse in other projects in this book.

Chapter 5, Using the AR User Framework, is where you will build a simple AR place-on-plane application using the AR user framework created in the previous chapter, including a main menu and a PlaceObject mode and UI. This chapter also discusses some advanced issues, such as making AR optional, determining device support, and adding localization to your projects.

Chapter 6, Gallery: Building an AR App, is part one of a two-chapter project. Here, you will develop a picture gallery application that lets you hang virtual framed photos on your real-world walls. In the process, you will learn about UX design, managing data and objects, menu buttons, and prefabs.

Chapter 7, Gallery: Editing Virtual Objects, is the second part of the Gallery project, where you will learn to implement interactions with virtual objects in your AR scene, including selecting and highlighting, moving, resizing, deleting, collision detection, and changing the photo in your picture frame.

Chapter 8, Planets: Tracking Images, shows you how to build an educational AR app that uses image tracking of Solar System "planet cards" that instantiates virtual planets hovering and spinning above your table.

Chapter 8, Selfies: Making Funny Faces, is where you will learn to use the front-facing camera of your device to make fun and entertaining face filters, including 3D heads, face masks (with choice of material textures), and accessories such as sunglasses and mustaches. It also covers advanced features specific to ARCore and ARKit that may not be generally supported by AR Foundation itself.

To get the most out of this book

First, you need a PC or Mac capable of running Unity. The minimum requirements are not difficult; almost any PC or Mac today will be sufficient (see

If you are developing for iOS, you will need a Mac running OSX with the current version of XCode installed, and an Apple developer account. If you are developing for Android, you can use either a Windows PC or Mac.

It is not practical to develop for AR without a device capable of running your application. You should have an iOS device that supports Apple ARKit (search the web; Apple does not appear to publish a list – check here, for instance:, or an Android device that supports ARCore (

In Chapter 1, Setting Up for AR Development, I walk you through installing Unity Hub, the Unity Editor, XR plugins for your target device, the AR Foundation toolkit package, and other software to get you set up. The projects in this book are written and tested with Unity 2021.1.

As the technology is rapidly evolving, I try to focus on existing stable tools and techniques. Regarding software versions and installation instructions, naturally, things can change, and I recommend you use my instructions as guidelines but also look at online documentation (links usually given) for the most current instructions.

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book's GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at If there's an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here:

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Utilizing the Unity Input System package, we will first add a new SelectObject input action."

A block of code is set as follows:

public void SetPlacedPrefab(GameObject prefab)


placedPrefab = prefab;


When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

using UnityEngine;

using UnityEngine.InputSystem;

public class GalleryMainMode : MonoBehaviour


void OnEnable()





Bold: Indicates a new term, an important word, or words that you see on screen. For instance, words in menus or dialog boxes appear in bold. Here is an example: "In the New Scene dialog box, select the ARFramework template."

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.