Setting up EasyAR Sense Unity Plugin¶
All Documents about EasyAR Sense Unity Plugin will be updated soon, more details and API descriptions are on the way...
This article shows how to setup EasyAR Unity projects using EasyAR Unity package.
Pre-Requirements¶
Unity 5.6.5f1 or later
(If target for Android) Unity 5.6.5f1 requires old Android SDK Tools 25.0.1, which is not required by more recent versions
(See Unity issue)
(If target for iOS) ARM64-CPU-based iPhone or iPad device, or other real Apple devices (EasyAR do not support running on the simulator or ARMv7)
EasyAR Package¶
There three EasyAR Sense Unity Plugin unitypackages.
Scenes contained in Basic unitypackages
HelloAR_BackAndFrontCamera Demonstrate how to switch between front and back camera
HelloAR_Coloring3D Demonstrate how to create a coloring book and "convert" book image into 3D at real-time
HelloAR_ImageTarget Demonstrate different methods to create targets; Demonstrate how to dynamically create targets
HelloAR_ImageTarget_Cloud Demonstrate how to use cloud recognition
HelloAR_ImageTarget_Video Demonstrate how to load video with Unity Video Player and play video on target
HelloAR_ImageTracking_ImageTargetData Demonstrate how to create a target from ImageTargetData
HelloAR_Multi_ImageTarget Demonstrate how to track multiple targets simultaneously using multiple trackers
HelloAR_SurfaceTracking Demonstrate how to use surface tracking
HelloAR_TargetOnFly Demonstrate how to create image target directly from real-time camera image and load it into tracker as a target
HelloAR_TransparentVideo Demonstrate how to load video with Unity Video Player and play transparent video with custom shader
Scenes contained in Pro unitypackages
HelloAR_ObjectTarget Demonstrate how to track 3D objects
HelloAR_Recorder Demonstrate how to do recording
Scenes contained in CustomCamera unitypackages
HelloAR_CustomCamera Demonstrate how to create an EasyAR app with a non-system-API-based camera
Notice that the Basic version does not contain features for the Pro version, thus scenes in Basic unitypackage and Pro unitypackage does not overlap, but Pro unitypackage contains all the code in Basic unitypackage.
Code, scenes and resources in Basic unitypackage can be copyed to project of Pro unitypackage.
The Basic and Pro versions both support CustomCamera.
Create Project¶
On creation of project, select 3D. EasyAR don't support other render pipelines(Lightweight RP, etc) now. If you'd like to use EasyAR with them, please implement camera background rendering by yourself.
Import Package¶
First, you have to download EasyAR Unity package (.unitypackage) and open to import it into Unity.
Folder Structure¶
[EasyAR] resources and code for EasyAR
[Common] common resources. Notice: it contains EasyARSetting which is used to fill the key
[Scripts] EasyAR sample core code, and low-level API interface file csapi.cs
[Shaders] common shader, and camera background, cube and transparent video related
[Plugins] Android/iOS/Window/Mac platform binaries and related interop code
[samples] sample resources and code
[Resources] EasyAR sample scene resources, corresponding to scenes
[Scenes] EasyAR sample scenes
[StreamingAssets] Unity non-compiling resource files, which can be used to load as target data
Initialize EasyAR¶
For EasyAR to work, a license key is required. You need to find EasyARKey, and insert the key in the inspector panel.
You can create a key after login EasyAR website. You can find how to create the key from Getting Started with EasyAR Sense.
Android API Level¶
EasyAR Sense requires Android Api Level 17 or later.
Bundle ID (Android/iOS)¶
You need to set bundle ID when generating Android/iOS apps. The bundle ID should match the ID where the key is generated in the EasyAR website. Otherwise the initialize will fail. One exception is for Mac or Windows; such ID matches are not required on these two platforms.
Graphics API (Android/iOS)¶
When using the HelloAR_Recorder sample on Android or iOS:
It is required to set Graphics API to OpenGL ES 2.0/3.0.
For Android, option Multithreaded Rendering need to be disabled.
Android setup
iOS setup, click the plus sign if no OpenGLES2 is shown.
disable bitcode option¶
EasyAR Sense does not support bitcode. It can be turned off by searching in BuildSetting in XCode and set it to NO.
iOS Privacy Settings¶
You can setup in Unity playerSetting
or
in Info.plist file in Xcode.
To use camera, add Privacy - Camera Usage Description,
To use screen recording feature, add Privacy - Microphone Usage Description,
iOS ARM64 support¶
Turn on IL2CPP in Player Settings and change the architecture to Universal or arm64. Mono scripting backend and armv7 for iOS are not supported any more.
Android ARM64 support¶
Unity support ARM64 on Android since 2017.4.
See Android documentation .
ARCore support¶
Install Google Play Services for AR on the phone via Google Play Store. Currently 1.6 and later are supported.
Ensure the following call is executed before use of ARCore.
System.loadLibrary("arcore_sdk_c");
(It is already in the examples.)
ARCore SDK upgrade¶
The version of the embedded ARCore SDK is 1.6, which support Google Play Services for AR 1.6 or later.
You can upgrade to newer ARCore SDK. Use 1.14 as an example.
Add the following line in the dependencies of app/build.gradle in any Android Studio project.
implementation 'com.google.ar:core:1.14.0'
Build, and core-1.14.0.aar is available in gradle cache. (Search in <computer user directory>/.gradle)
Open as a .zip file, and copy classes.jar to Assets/Plugins/Android/libs, renamed to arcore-classes.jar, copy and overwrite libarcore_sdk_c.so inside jni/armeabi-v7a and jni/arm64-v8a to corresponding directories in Assets/Plugins/Android/libs.