Table of Contents

Get started with EasyAR Unity development using examples

This tutorial explains how to configure and run EasyAR Unity examples to quickly get started with AR development.

Prepare an empty Unity project

Ensure that a compatible Unity version (Unity 2021.3 or later) is installed. It is recommended to use the latest version of Unity 2022.3 or Unity 6.3.

Create an empty Unity project using the 3D (Built-in Render Pipeline) template:

Note

It is not recommended to use URP for first-time use.

If you are using Unity 6, you need to manually download and use the 3D (Built-In Render Pipeline) Template. By default, it is located further down in the template list.

Important

To use URP, additional configuration must be performed according to Universal Render Pipeline (URP), otherwise the camera feed will not be displayed.

Import EasyAR Sense Unity Plugin

  • Download the plugin package
    • Download the latest version of EasyAR Sense Unity Plugin, which includes samples.
    • After extracting the downloaded zip package, you will find a readme and .tgz file. The .tgz file can be directly imported into Unity and should not be extracted.
    • Store the .tgz file in the Packages folder of your Unity project.
  • Import the plugin package
    • From the menu bar, click Window and select Package Manager.
    • In the pop-up window, click the + sign in the top-left corner and choose Install Package from tarball ....
    • In the dialog box that appears, select the aforementioned .tgz file.

ImportUnityPlugin

Note

The .tgz file cannot be deleted or moved to another location after being imported into Unity. It should be placed in a suitable location before import. It is generally recommended to store it in the Packages folder of the Unity project for version control.

Import samples

Open the Package Manager via the menu Window > Package Manager, select EasyAR Sense Unity Plugin, and choose **All Samples** on the right side to import all samples at once.

ImportSample

Caution

**All Samples** and other samples cannot be imported simultaneously, as this may result in duplicate assets and cause some scene resources to be lost. If duplicate files are accidentally imported, delete them and re-import.

Modify the scene list

Open Build Settings (or Build Profiles),

Add the sample scenes from the Unity project to the Scene List in Build Settings or Build Profiles, and move the launcher scene (AllSamplesLauncher) to the first position among all scenes.

Caution

Do not add these headset-related scenes, as it may cause the build to fail:

  • Combination_BasedOn_AppleVisionPro.rst
  • Combination_BasedOn_Xreal.rst

Fill in the license (License Key)

From the Unity menu, select EasyAR > Sense > Configuration to bring up the EasyAR Sense settings interface.

FillInKey

Enter the EasyAR Sense License in the input box under EasyAR Sense License.

FillInKey2

Tip

The EasyAR Sense License can be created from the EasyAR Developer Center (Chinese, English). For first-time use, you can follow these steps to create one:

  • Create EasyAR Sense 4.x Personal Edition
  • Select Yes for sparse spatial map and fill in any name
  • Fill in any application name, and enter com.mycompany.myproject for Bundle ID and Package Name
  • Select the newly created License, then click the copy button on the right

copykey

Note

The Bundle ID and Package Name can be changed later, but the number of changes is limited. If you have a specific application package name, you can also enter your own package name.

There is no limit to the number of personal editions you can create. Other types can be created as needed for formal use.

Run in the editor

Running in the editor requires a camera connected to your computer.

Confirm the system camera is working properly

Open the system camera app:

Confirm the camera can function normally:

Finally, make sure to close the camera app to avoid conflicts when running the sample.

Note

EasyAR only uses the system-provided interface to open the camera. Ensure the system camera app can open the camera and display properly.

Run the example

The following content takes the image tracking example ImageTracking_Targets as an example. Other examples can be run in a similar way.

Open the sample launcher scene and click the Play button at the top of the Unity editor.

Enter the ImageTracking_Targets scene.

Tip

You can also directly open the ImageTracking_Targets scene and execute it.

Point the camera at the following target image:

namecard

Download link: 🔗 namecard

EasyAR will recognize and track this image and overlay virtual objects.

Note

Some features cannot be run in the editor by connecting to the camera but can be run on a mobile device. Examples that cannot be used in the editor will display a pop-up window indicating startup failure.

At the same time, there will be a message prompt and error log output.

Running on mobile

To run on mobile, you need to package the app. Before packaging, you need to modify the Player configuration.

Modify player configuration

In the Unity menu, go to File > Build Settings > Player Settings, click the Android icon to bring up the corresponding settings for the Android platform.

switchtoandroid

  • Change the Package Name to the Package Name displayed on the License Key page

    androidPackageName

    Tip

    For example, if the Package Name you entered when creating the License Key was com.mycompany.myproject, you must set the Package Name here to com.mycompany.myproject, otherwise it will fail to run.

  • Change the Minimum API Level to API Level 21 or higher

    androidAPILevel

  • Change the Scripting Backend to IL2CPP and check ARM64 in Target Architecture

    androidarm64

Package the application

Select File > Build Settings, choose the target platform (Android/iOS), and then select switch platform.

switchplatform

Select Build or Build And Run to compile the project and install it on your phone. During runtime, the corresponding permissions need to be granted.

buildandrun

Running the example

The following content takes the image tracking example ImageTracking_Targets as an example. The running method of other examples is similar.

After running, the example launcher scene should be started.

Tip

If the example launcher scene is not entered after opening, you need to check whether the scene list in Build Settings or Build Profiles is correctly set, and move AllSamplesLauncher to the first position.

Enter the ImageTracking_Targets scene.

Aim the phone camera at the following recognition image:

namecard

Download link: 🔗 namecard

EasyAR will recognize and track this image and overlay virtual objects.

Next steps

You have successfully run the Unity AR sample and may be interested in how the AR scene demonstrated in the sample was created. You can read the following getting-started guides in order:

For the sample launcher, you can refer to the detailed usage instructions:

If you want to understand the complete project configuration, you can refer to the following content:

If you want to learn more about how to use EasyAR, you can start here: