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-**.tgzandcom.easyar.mega-**.tgzpackages 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.
- Open Package Manager using menu
Window>Package Manager, selectEasyAR Sense Unity Plugin. Expand all samples in the Samples section on the right. - Select a sample (e.g.
MegaBlock_Basic), click Import.

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
- Select
EasyAR>Sense>Configurationfrom the menu bar;

- Paste your License Key in the opened Project Settings panel;

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
Nofor sparse spatial map - Fill in any application name, enter
com.mycompany.myprojectfor Bundle ID and Package Name - Select the newly created License, then click the copy button on the right

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.
- Configure your Mega cloud localization library information in the
Mega Blocksection of the Project Settings panel;

Tip
Mega cloud localization library configuration can be obtained from the EasyAR Developer Center.

Ensure your API Key has permissions for Mega Block. Modify or recreate if necessary.

Step 3: Place 3d content
Right-click on a blank area in the
Hierarchypanel to add a Block viewer (Unity development);

Access Mega localization service;
- Select the
EasyAR.Mega.BlockViewer (Dev)node, fill in your EasyAR account credentials in the Inspector panel, and log in;

- Click the button to the right of Mega Cloud Service;

- Select the
Mega localization serviceyou want to use, then click OK.

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

After loading, the Block will display in the
Scenewindow. You can manipulate the view angle and position in theScenewindow. 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).

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

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 transformof theBlock_*node, as it is managed automatically by the tool.
- 3D objects must be placed under the automatically generated
Step 4: Configure MegaTracker
Configure Block Root;
Expand
AR Session, selectMega Block Tracker, and setBlock Rootto theMegaBlocksnode generated by the tool.

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.

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

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 tocom.mycompany.myproject, otherwise it will fail to run.Change the Minimum API Level to
API Level 21or higher
Change the Scripting Backend to
IL2CPP, and checkARM64inTarget Architecture
Step 6: Build and run
- Add the current scene to
File>Build SettingsorBuild Profiles>Scene List; - Switch to the target platform (e.g., Android/iOS), and verify that the package name (Bundle ID) matches the License Key;

- Click 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.
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.
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:
- Onsite and simulation
- ARSession best practices
- Add tracking targets
- Create 3D content aligned with the real world
- Environment occlusion (Occlusion)
- Control tracking process
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:



