Table of Contents

Initialize EasyAR Sense with License Key

To use EasyAR in Unity, you need to initialize EasyAR Sense with a license key to ensure the functionality is activated. There are two initialization methods: automatic initialization and manual initialization.

After successful initialization, you can see the version number and platform information of EasyAR Sense in the Unity console or system logs, for example:

EasyAR Sense (Android-arm64) Version 4.7.0.11800-cf8e24e30

Before you start

  • EasyAR Sense License describes how to obtain an EasyAR Sense license (license key). Before initializing EasyAR Sense, you need to prepare a suitable license according to the actual device and development stage.

Auto initialization

Auto initialization is suitable for most usage scenarios.

Open EasyAR Global Config, check the Initialize On Startup option, and fill in EasyAR Sense License > LicenseKey

alt text

Auto initialization will automatically be called at Unity's BeforeSceneLoad timing.

Note

The license used in the editor does not verify the application package name, so a license that works normally in the editor may still fail when packaged into a platform application or app runtime. In this case, pay attention to two situations:

  1. The package name of the filled license should match the bundle id/package name filled in Unity Player Settings.
  2. If the package name is modified in the gradle or XCode project after Unity packaging. In this case, use the package name in gradle or XCode in Unity.

[Optional] Manual initialization

Manual initialization is mainly used for custom initialization processes, such as displaying a user privacy statement before calling the EasyAR interface (please refer to the Compliance Guide).

Open EasyAR Global Settings and uncheck the Initialize On Startup option.

alt text

Then use the EasyARController.Initialize() interface to manually call initialization.

You can pass the license as a parameter,

EasyARController.Initialize("my-license");

or use the license filled in the EasyAR Global Settings,

EasyARController.Initialize();
Important

EasyARController.Initialize() must be called before starting ARSession.

In some special cases, if you need to call EasyARController.Initialize() multiple times, make sure to deinitialize after each EasyARController.Initialize() execution using EasyARController.Deinitialize().

Solution for initialization failure

After running the scene containing ARSession, if the log does not contain similar information, it means the initialization has failed.

EasyAR Sense (Android-arm64) Version 4.7.0.11800-cf8e24e30

In the Unity editor, you may also see a pop-up window like this:

alt text

Note

Pay attention to the text information displayed in the pop-up window, as not all pop-ups indicate initialization failure.

Common error messages and their causes are as follows:

  • EasyARSettings is not found
    • The EasyAR global configuration resource file has not been created (commonly occurs when the license is not filled in)
  • License Key is empty
    • The license is not filled in the EasyAR global configuration, or there are multiple EasyAR global configuration resource files in the project
  • EasyARController.Initialize is not called (InitializeOnStartup = false)
    • Manual initialization was not called at the correct time
  • EasyAR stops after script change in play mode
    • The script was modified while running in the editor. In this case, simply restart the run