Working with AR Foundation¶
AR Foundation Versions Supported by EasyAR¶
EasyAR Sense Unity Plugin support AR Foundation 4.0.8 or later.
Import AR Foundation Package¶
Skip this step if you already have a usable AR Foundation project.
Import AR Foundation
Unity Package using Unity Package Manager,
To use AR Foundation on Android or iOS, usually you need to import either ARCore XR Plugin
or ARKit XR Plugin
Unity package into the project. Follow AR Foundation Introduction to setup necessary packages.
Create a Scene Usable that can run AR Foundation¶
Skip this step if you already have a usable Foundation project.
Follow AR Foundation Introduction to create a usable scene that can run AR Foundation.
A typical AR Foundation scene contains an AR Session
and an AR Session Origin
.
It is suggested to make sure the scene could be used normally before adding EasyAR components into the scene.
Add EasyAR Components in the Scene¶
NOTE: AR Foundation
usually sets its clipping planes to (0.1, 20) , this may clip objects away displayed more than 20 meters from the Camera (the device in real world). Please make sure to change its value for your needs before you use them.
Add EasyAR AR Session and other necessary nodes in the scene. You can reference Start from Zero for startups. AR Session can be created from some AR Session presets or constructed from standalone feature nodes using EasyAR Sense >
GameObject menu. You need to make sure there is a ARFoundationFrameSource in the session.
AR Session presets from SpatialMap
, Cloud SpatialMap
, Motion Tracking
contain ARFoundationFrameSource
AR Session presets with the name Motion Fusion
from Image Tracking
and Object Tracking
also contain ARFoundationFrameSource
To use EasyAR with AR Foundation, ARFoundationFrameSource must be selected as frame source in the AR Session after Session start.
This could usually be done by set ARComponentPicker.FrameSource to FirstAvailableActiveChild
and make sure ARFoundationFrameSource is the first frame source that can be used in transform order,
The NrealFrameSource in above image will not be chosen if Nreal SDK is not imported and added into the scene, so it is safe in this kind of usage.
Or set ARComponentPicker.FrameSource to Specify
and specify the frame source to ARFoundationFrameSource .
ARFoundationFrameSource can be added to AR Session from menu EasyAR Sense > Motion Tracking > Frame Source : AR Foundation
if it does not exist in the session.
Then add targets or maps in the scene, for example, if you want to build Sparse SpatialMap
, you need to create SparseSpatialMapController by EasyAR Sense > SpatialMap > Map : Sparse SpatialMap
Finally, a simple scene for sparse and dense spatial map building with AR Foundation could look like this,
Scenes can be different according to features in use from both AR Foundation and EasyAR Sense Unity Plugin.
Choose AR Foundation in Runtime¶
MotionTracking_Fusion
sample shows an advanced usage, to choose frame source at app start up according to device capability and enables runtime switch of available frame sources. To achieve this kind of usage, you need to deactive AR Foundation GameObjects and set all required values of all frame sources for availability check, and active AR Foundation GameObjects when this frame source is chosen.
There are more details in ARFoundationFrameSource.