AR Foundation Configuration¶
When to Use AR Foundation¶
Unity AR Foundation provides a wrapper for some cross-platform motion tracking capabilities. Please read Motion Tracking and EasyAR Features to understand the relationship between EasyAR features and motion tracking, and determine whether and when to use AR Foundation.
In most cases, you can work without AR Foundation, and EasyAR will function properly on all supported devices. You should consider using AR Foundation in the following two scenarios:
If you need to use ARCore on all Xiaomi and Redmi phones that support ARCore, use AR Foundation. Due to bugs in Xiaomi’s implementation, EasyAR’s ARCore implementation has disabled some Xiaomi phones, including the Mi 9, Mi 10, Redmi K20, Redmi K30, Redmi K40 series, etc. (this list is not exhaustive and may be adjusted as needed). On these phones, ARCore will not be used by default, and EasyAR motion tracking will be used on phones that support EasyAR motion tracking.
If you need to use certain features provided by ARCore or ARKit that are not wrapped in EasyAR, you can also use AR Foundation. For example, AR Foundation provides support for ARKit’s
ARKitFaceManager
, which is not wrapped in EasyAR.
However, using AR Foundation may not always be optimal for EasyAR’s features:
When using EasyAR Mega, the default configuration of AR Foundation is not optimal. Although EasyAR provides options for optimization, note that some phones (e.g., Xiaomi Mi 10) have bugs that prevent image acquisition after modifying the configuration, rendering EasyAR unusable. Use with caution.
On some Xiaomi phones disabled by EasyAR, the input data to EasyAR is grayscale rather than color, which may affect the performance of certain algorithms.
Supported AR Foundation Versions in EasyAR¶
EasyAR Sense Unity Plugin supports AR Foundation 5.1.6 or later. Only Unity.XR.CoreUtils.XROrigin
is supported, and ARSessionOrigin is not supported.
Attention
AR Foundation support is implemented as EasyAR Sense custom camera. EasyAR Sense will stop responding after a fixed and limited time per run if trial product (personal license, trial XR license, or trial Mega services, etc.) is being used with custom camera or HMD. There is no limitation when using a paid license for EasyAR Sense and paid EasyAR Mega service.
Importing EasyAR ARFoundation Support Package¶
Use Unity’s Package Manager window to install using a local tarball file the EasyAR ARFoundation support package (com.easyar.arfoundation
).

The EasyAR ARFoundation support package will automatically import AR Foundation
, Google ARCore XR Plugin
, and Apple ARKit XR Plugin
. Although the automatically imported files are usually ready to use, it is recommended to manually check for updates to ensure you have the latest bug fixes.

Attention
Ensure that the versions of Google ARCore XR Plugin
and Apple ARKit XR Plugin
match the version of AR Foundation
exactly. Version mismatches may cause runtime errors.
Configuring XR Plug-in Management¶
Follow the AR Foundation Introduction under Project Setup > Install AR Foundation
for configuration. Be sure to select the version of AR Foundation you are using.
Generally, before using AR Foundation, you need to enable XR Plug-in Management in Unity to support AR Foundation:
In
Project Settings > XR Plug-in Management
, select the current platform and checkInitialize XR On Startup
.

If you need to control the initialization timing freely, ensure that AR Foundation initialization is called before EasyAR ARSession’s Assemble
.
In
Project Settings > XR Plug-in Management
, select the current platform and check the plug-in providers for the current platform.For Android, select
Google ARCore
.For iOS, select
Apple ARKit
.


It is recommended to set
Requirement
toOptional
andDepth
toOptional
inProject Settings > XR Plug-in Management > Google ARCore
to ensure the application can run on phones that do not support ARCore.

It is recommended to set
Requirement
toOptional
inProject Settings > XR Plug-in Management > Apple ARKit
to ensure the application can run on phones that do not support ARKit.

Configuring URP¶
If you are using URP, you need to perform specific configurations. Users of other rendering pipelines can skip this step.
Follow the AR Foundation Introduction under Project Setup > Universal Render Pipeline
for configuration. Be sure to select the version of AR Foundation you are using.
Refer to Unity’s official documentation to correctly configure URP and add ARBackgroundRendererFeature
. Details are not described here.

Additionally, you still need to configure EasyAR’s EasyARCameraImageRendererFeature
similarly, as described in Universal Render Pipeline (URP) Configuration, to ensure proper rendering for both EasyAR and AR Foundation.
Adding Unity AR Session and XR Origin¶
Follow the AR Foundation Introduction under Project Setup > Scene Setup
to add AR Foundation components. Be sure to select the version of AR Foundation you are using.
You need to add AR Session and XR Origin to the scene.
If your scene already contains a
Camera
, delete it.

If your scene already contains
XR Origin (EasyAR)
, delete it.

Move all child objects under this node to the newly created XR Origin node below. If not moved, these child objects will not work as expected.
Use the context menu
XR > AR Session
to add Unity’s ARSession to the scene (this is different from EasyAR’s ARSession and does not conflict).

Use the context menu
XR > XR Origin (Mobile AR)
to add Unity’s XR Origin to the scene (similar to EasyAR’s XR Origin, you need to delete EasyAR’s XR Origin).

Adjust Camera parameters as needed.

AR Foundation
typically sets its clipping planes to (0.1, 20), which may cause objects farther than 20 meters from the Camera (the real-world device) to not display. Modify as needed before use.
Configuring EasyAR ARSession¶
Ensure that EasyAR’s ARSession contains the FrameSource you need.
ARSessions created through menus (e.g., EasyAR Sense > Mega > AR Session (Mega Block + MotionTracking Preset)
) will automatically include ARCore ARFoundation
and ARKit ARFoundation
(except for some image tracking and other features that do not require SLAM functionality).

If they are not in your ARSession, you can manually add them through the menu.

After adding, you usually need to sort the FrameSource using the menu.

It is generally recommended to click all the following sorting options (same as EasyAR’s default ARSession):
Sort Frame Source : ARCore > ARCore ARFoundation
Sort Frame Source : ARKit > ARKit ARFoundation
Sort Frame Source : System SLAM > Motion Tracker
You can also freely adjust the FrameSource priority, as long as the most preferred source is moved ahead of the less preferred ones. At runtime, the tree order determines which FrameSource is used when available.
Properly handle all AR Foundation-related scripts to ensure AR Foundation is enabled only on required devices, while EasyAR’s corresponding features are used on other devices.
You can directly enable the Auto Unity XR Switch
option in ARSession to automatically handle these script toggles.

If you have custom requirements or Auto Unity XR Switch
does not work properly, you need to handle it manually. You need to:
Disable AR Foundation’s ARSession in the editor.
Disable all Unity XR Core components, AR Foundation components, and related components or features you need to control before AR Foundation starts working.
If EasyAR’s ARSession’s Assemble process selects ARCoreARFoundationFrameSource or ARKitARFoundationFrameSource, enable all previously disabled components or features.
If EasyAR’s ARSession’s Assemble process selects another FrameSource, leave it unchanged.