Table of Contents

Getting started with easyar mega unity development with samples

This tutorial shows you how to configure and run the easyar mega unity samples to quickly get started with easyar mega development.

Before you begin

Ensure you have completed the following before reading this section:

  • Possess a valid cloud-based localization library.
  • Install Unity (2021.3.30 LTS or later). Unity 2022.3 or the latest Unity 6.3 version is recommended.
  • Import the com.easyar.sense-**.tgz and com.easyar.mega-**.tgz packages using the method described in Enabling MEGA.

Example usage in six steps

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

Step one: Import sample

Note

If all samples were imported via **All Samples**, this step can be skipped.

  1. Open Package Manager using menu Window > Package Manager, select EasyAR Sense Unity Plugin. Expand all samples in the Samples section on the right.
  2. Select a sample (e.g. MegaBlock_Basic), click Import.

Import Sample

Note
  • This tutorial cannot be directly applied to headset devices, but understanding the workflow through mobile development is required before developing for headsets.
  • If you previously imported samples from older SDK versions, delete old samples before re-importing after upgrading the SDK.

Step 2: Fill in 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. First-time users can create it as follows:

  • Create EasyAR Sense 4.x Personal Edition
  • Select No for sparse spatial map
  • Fill in any application name, 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 modified later, but with limited attempts. If you have a specific application package name, you may enter your own.

There is no limit to creating Personal Edition licenses. Other types can be created as needed for official use.

  1. Configure your Mega cloud localization library information 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. Modify or recreate if necessary.
API Key Auth

Step 3: Place 3d content

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

  2. Access Mega localization service;

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

    After selecting the service, the Block list in the current library will display under the MegaBlocks node and appear in the tool panel. Click Load to load the selected Block:
    Load Block

    After loading, the Block will display in the Scene window. You can manipulate the view angle and position in the Scene window. Simultaneously, check if the Block file is usable (e.g., whether the Block coordinate system is normal, if layers exist, or if it's too blurry/damaged to locate positions for placing AR content).
    Display Block

  4. Place 3d content

    You can now place 3D objects with reference to the Block.
    Place 3D Object

    Note
    • 3D objects must be placed under the automatically generated MegaBlocks > Block_* node to ensure correct rendering positions of virtual content during runtime.
    • Do not modify the name or local transform of the Block_* node, as it is managed automatically 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 filled in when creating the License Key is com.mycompany.myproject, then 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 verify that the package name (Bundle ID) matches the License Key;
    Switch Platform
  3. Click Build And Run.
    Build And Run

The actual running effect captured on-site is as follows:

About the yellow text on screen

During runtime, you may notice two areas of yellow text displayed on the screen.

  1. Simulation run warning message

    It appears at the bottom of the screen:

    This warning appears because, under the default configuration, the app can run without being on-site. It has a slight impact on the app's performance. If you are 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 status and issues. It is recommended to keep it displayed during development and testing phases:

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

Next steps: from beginner to proficient

Congratulations! By following the steps above, you have successfully run the core sample of EasyAR Mega within 10-minutes, personally experiencing the charm of spatial localization and AR content overlay.

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

  • Build more stable and efficient AR applications
  • Achieve complex effects like virtual-real occlusion and content alignment
  • Debug when devices are unavailable or on-site visits are impossible

Please refer to the following in-depth guides. They will help you solve practical problems encountered during development.

Advanced development

If you wish to understand the complete project configuration, you can refer to the following:

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

Additionally, it is recommended to read the following to assist your development and debugging:

Fine-grained control of mega functions

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

The following will help you verify Mega functions without being onsite:

Advanced topics

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

If you wish to run EasyAR Mega on headsets, you can refer to the following:

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