Unity Package

Unity Package

Requirements

  • ARCloud project from Graffity Console
  • This package is tested with the following versions of the Unity Editor (opens in a new tab) with Android and/or iOS modules:
    • 2019.4.15f1
    • 2020.3
    • 2021.1
    • 2021.2
  • Android or iOS Device to run AR app
  • Xcode is required for the iOS build

Installing Graffity's ARCloud Package

Step 1 - Installing Git and Git-LFS

Install git and git-lfs (opens in a new tab) on your machine to download package artifacts properly. See more information (opens in a new tab) from GitHub and make sure it installs on the system root with the following command.

sudo git lfs install --system

Note that Apple Silicon may face with command not found. You can fix it here (opens in a new tab).

Step 2 - Install the package from Git URL below using the UPM method. See Unity's official documentation Installing from a Git URL (opens in a new tab).

https://github.com/Graffity-Technologies/graffity-arcloud-unity.git

You can also specify the package version (opens in a new tab) with # follow by tag name.

https://github.com/Graffity-Technologies/graffity-arcloud-unity.git#2.1.0

Scene Setup

Step 1 - AR Scene Setup.

Step 2 - Import Reference Point Cloud.

  • In the root of the scene, Create Empty rename it to ReferencePointCloud.

  • Add Reference Point Cloud, .ply file, of AR development location to project assets directory. Then add it to ReferencePointCloud.

  • **ensure ReferencePointCloud world coordinate (0, 0, 0) and world rotation (0, 0, 0). In other words, no rotation and translation relative to world space.

  • **Change ReferencePointCloud scale to (-1, 1, 1)

Point Cloud

Step 3 - Set up ARCloud Session.

  • Create API credential config

    • Right-click in the project window and select Create > AR Cloud > API Credential Config.
    • Setting up the Access Token field, which is generated from the Graffity Console project.

    Add Token

  • Add ARCloud Session Script to the existing AR Session Origin object. There should be only one ARCloud Session instance in the scene.

  • Reference created API Credential Config and ReferencePointCloud to ARCloud Session Script.

    Point Cloud 2

Step 4 - Incorporate AR Cloud Session in your code.

  • There are two essential methods used to control ARCloud Session.

  • Call the Init method to set up the session. Assign Latitude and Longitude field to where Reference Point Cloud is located. The Altitude field should be left to zero.

ARCloudSession.instance.Init(new PositionGps(){
    Latitude = POINT_CLOUD_LATITUDE, // ex. 13.729508407345941
    Longitude = POINT_CLOUD_LONGITUDE, // ex. 100.53591335616113
    Altitude = 0.0 
});
  • Call the StartLocalize method to start the localizing operation with strategies of the localization process, the default is LocalizeStrategy.LAST_POINT_DIFF_MEDPRECISION.
ARCloudSession.instance.StartLocalize(LocalizeStrategy.LAST_POINT_DIFF_MEDPRECISION);

The localization progress and state can be inspected from localizeState and localizeProgress member of ARCloudSession.

Pre-build Configs

Step 1 - Hide the point cloud before building to devices by unchecking the render option from Inspector because the point cloud is just for visualization in the editor.

Point Cloud 3

Step 2 - Project Settings > Player > XR Plug-in Management

Make sure you enable ARKit for iOS or ARCore for Android on your preferred OS.

Step 3 - Build Settings

Build a scene to the device on your preferred OS.

Tips

Adjust Point Cloud Size

Create the custom point, which refers to Point Cloud/Point Shader, and change the material to the created custom point.

Point Cloud 4

Point Cloud 5

Change camera rendering range

Config Clipping Planes Near and Far to adjust rendering range in AR session.

Point Cloud 6

Zoom In to Point Cloud

Double-click on the point cloud object to zoom into the point cloud view.

Point Cloud 7

Report Issues

If you're facing any issues related to this package, please find out here.