How to Use Samples¶
Preparation¶
Prepare Unity Environment¶
Read Platform Requirements to learn system and Unity versions EasyAR Sense Unity Plugin support and get Unity packages from the Unity website.
If it is your first time, suggest using LTS Releases from Unity.
Prepare Package¶
Get latest EasyAR Sense Unity Plugin package from download page. Samples are included in the package. Please reference Plugin Introduction for the file to download and contents inside the downloaded file.
Get Licensing¶
Before using EasyAR Sense, you need to register on www.easyar.com and get a license key .
Editor Project Configuration¶
Create Empty Unity Project¶
Choose 3D, Core template When create a project. If you are using URP (default in Unity 6), you need to reference Universal Render Pipeline (URP) Configuration for Configuration.
Add Plugin Package¶
The plugin use Unity’s package to organize itself. It is distributed as a tarball file. You will get readme files and a tgz file after extracting the downloaded zip file. Do not extract the tgz file.
Note
It is suggested to put above tgz file inside the project, like in the Packages folder. Use Unity’s Package Manager window to install the plugin from a local tarball file.
Choose the com.easyar.sense-*.tgz file in the popup dialogue.
Note
The tgz file cannot be deleted or moved to another place after import, so it is always a good practice to find a suitable place for the file before import. If you want to share the project with others, you can put the file inside the project and your version control system.
Import Sample(s) into Project¶
The samples are distributed within the plugin package. You can import samples into your project using Unity’s Package Manager window.
You can import all samples together using **All Samples**, or import individual sample with the sample name.
Note
**All Samples** cannot be imported together with any other individual samples to the same project, there would be duplicate assets and cause scene asstes missing otherwise. Please delete all imported samples and import again if duplicate samples were imported by mistake.
Setup EasyAR Project¶
Fill in License Key.
Choose EasyAR > Sense > Configuration from Unity menu and fill in the License Key in the Project Settings. This page can be also opened from Edit > Project Settings > EasyAR.
Some samples use EasyAR services and service configurations are required. Skip if these samples are not used.
Above simple configuration is enough if this is your first time using EasyAR. For more configuration, Please reference EasyAR Settings.
Add scenes¶
Open Build Settings or Build Profiles,
Add sample scenes of the Unity project into Build Settings or Scene List in Build Profiles. Move the launcher scene (AllSamplesLauncher) to the top if there is a one in the project.
Do not add samples for HMD if running on mobile phones, build will fail otherwise:
Combination_BasedOn_AppleVisionPro.rst
Combination_BasedOn_Xreal.rst
Run in the Editor¶
If you have AllSamplesLauncher scene, you can open it (double click scene file or use File > Open Scene) and it can launch all samples. Or you can choose to open (double click scene file or use File > Open Scene) a single sample scene to run.
If a camera is connected to the computer, it can run EasyAR Sense Unity Plugin samples from Unity Editor after the above configurations.
Note that not all features can run in the editor using cameras. Some of them can only run on Android or iOS devices. Dialogue for session start fail message will popup when running these samples in the editor.
And there will be UI messages and error logs,
Note
Algoth these samples cannot run in the editor using cameras, but you can run in the editor for many of them (like SpatialMap samples) using pre-recorded eif files for simulation. Please refernece EasyAR Input Frame (EIF) Recording and Playback and Session Validation Tool for details.
Run on Android or iOS Devices¶
Configure the project according to Android Project Configuration or iOS Project Configuration, switch to target platform and then click on the Build or Build And Run button in Build Settings or use other alternatives will compile the project and install the binaries on the phone. Permissions should be granted on the phone when running.