Table of Contents

Get started with EasyAR Mega Unity development using examples

This tutorial explains how to configure and run the EasyAR Mega Unity example to quickly get started with EasyAR Mega development.

Before you begin

Before reading this article, make sure you have completed the following:

  • Have a valid cloud localization library.
  • Install Unity (2021.3.30 LTS or later). It is recommended to use the latest version of Unity 2022.3 or Unity 6.3.
  • Import the com.easyar.sense-**.tgz and com.easyar.mega-**.tgz packages as described in Enable Mega.

Example usage method (six steps)

The following will introduce how to configure and run the core example MegaBlock_Basic of EasyAR Mega in six steps.

Step 1: Import samples

Note

If all samples have been imported via **All Samples**, you can skip this step.

  1. Use the menu Window > Package Manager to open the Package Manager, select EasyAR Sense Unity Plugin, and expand all samples in the Samples section on the right.
  2. Choose a sample (e.g., MegaBlock_Basic) and click Import.

Import Sample

Note
  • This tutorial cannot be directly applied to head-mounted devices, but you need to understand the process using mobile development before developing for head-mounted devices.
  • If you have previously imported samples from an older version of the SDK, you need to delete the old samples and re-import them after upgrading the SDK.

Step 2: Fill in the license key and configure Mega cloud localization service

  1. Select EasyAR > Sense > Configuration from the menu bar;
    License Guide
  2. Paste your License Key in the opened Project Settings panel;
    Fill License
Tip

EasyAR Sense License can be created from the EasyAR Developer Center. For first-time use, follow these steps to create one:

  • Create EasyAR Sense 4.x Personal Edition
  • Select No for sparse spatial map
  • Fill in the application name freely, and enter com.mycompany.myproject for Bundle ID and Package Name
  • Select the newly created License, then click the copy button on the right

copykey

Note

Bundle ID and Package Name can be changed later, but the number of changes is limited. If you have a specific application package name, you can also enter your own.

There is no limit to the number of personal editions created. Other types can be created as needed for formal use.

  1. Configure the information of your Mega cloud localization library in the Mega Block section of the Project Settings panel;
    Mega Config Guide
Tip

Mega cloud localization library configuration can be obtained from the EasyAR Developer Center.
Mega Config Detail
Ensure your API Key has permissions for Mega Block. If not, make changes or create a new one.
API Key Auth

Step 3: Place 3D content

  1. Right-click on a blank area in the Hierarchy panel to add the Block viewer tool (Unity development);
    Add Block Viewer

  2. Access the Mega localization service;

    1. Select the EasyAR.Mega.BlockViewer (Dev) node, and fill in your EasyAR account information in the Inspector panel to log in;
      login
    2. Click the button on the right side of Mega Cloud Service;
      Click Mega CLS
    3. Select the Mega localization service you want to use and click OK.
      Select Mega CLS
  3. Load Block

    After selecting the service, the Block list in the current library will be displayed under the MegaBlocks node and shown in the tool panel. Click Load to select the Block:
    Load Block

    After loading, the Block will be displayed in the Scene window. You can operate in the Scene window to adjust the viewing angle and position. Also, check whether the Block file is usable (e.g., whether the Block coordinate system is normal, whether there are layers, whether it is too blurry or damaged to find a position to place AR resources, etc.).
    Display Block

  4. Place 3D content

    At this point, you can refer to the Block to place 3D objects.
    Place 3D Object

    Note
    • 3D objects must be placed under the automatically generated MegaBlocks > Block_* node to ensure the rendering position of the virtual content is correct at runtime.
    • Do not modify the name of the Block_* node or its local transform, as it is automatically managed by the tool.

Step 4: Configure MegaTracker

  1. Configure Block Root;

    Expand AR Session, select Mega Block Tracker, and set Block Root to the MegaBlocks node generated by the tool.
    Set Block Root

Step 5: Modify player configuration

In the Unity menu, go to File > Build Settings > Player Settings, click the Android icon to bring up the corresponding settings for the Android platform.

switchtoandroid

  • Change the Package Name to the Package Name displayed on the License Key page.

    androidPackageName

    Tip

    For example, if the Package Name you entered when creating the License Key was com.mycompany.myproject, you must set the Package Name here to com.mycompany.myproject, otherwise it will fail to run.

  • Change the Minimum API Level to API Level 21 or higher.

    androidAPILevel

  • Change the Scripting Backend to IL2CPP and check ARM64 in Target Architecture.

    androidarm64

Step 6: Build and run

  1. Add the current scene to File > Build Settings or Build Profiles > Scene List;
  2. Switch to the target platform (e.g., Android/iOS) and check if the bundle ID and license key match;
    Switch Platform
  3. Click Build And Run.
    Build And Run

The live-captured running effect is as follows:

About the yellow text on the screen

During runtime, you may see two instances of yellow text displayed on the screen.

  1. Simulation run warning message

    It appears at the bottom of the screen:

    This warning appears because, by default, the app can run without being on-site. It has a slight impact on the app's performance. If you happen to be using it on-site, you can modify the MegaTracker configuration before building.

  2. Diagnostic information

    It appears at the top of the screen and is used to understand the session's status and issues. It is recommended to keep it displayed during development and testing:

    You can refer to Diagnostic information in the scene to quickly learn how to configure and use this diagnostic information.

Next steps: From beginner to master

Congratulations! By following the steps above, you have successfully run the core samples of EasyAR Mega in 10 minutes, experiencing the charm of spatial positioning and AR content overlay firsthand.

Now that you have mastered the basics. If you want to:

  • Build more stable and efficient AR applications
  • Achieve complex effects like virtual-real occlusion and content alignment
  • Debug when you don’t have the device or can’t go on-site

Refer to the following in-depth guides, which will help you solve practical problems during development.

Development advanced

If you want to learn about the complete project configuration, you can refer to the following:

If you want to further understand how to use EasyAR, you can start here:

At the same time, it is recommended to read the following to assist your development and debugging:

Fine-grained control of Mega features

The following content will help you better use Mega in your application:

The following content will help you verify Mega features without visiting the site:

Advanced topics

The following content is more suitable for reading after having some experience with EasyAR.

If you want to run EasyAR Mega on a headset, you can refer to the following:

If you want to use AR Foundation, you can start here: