Unity SDK
Add AR Clip VPS to a Unity project. The SDK finds the user's position on your VPS maps and places content in the right spot, on ARKit (iOS) and ARCore (Android) devices.
Before you start
- Unity 2022.3 LTS or newer
- A test device with ARKit or ARCore support
- Git LFS, if you clone the sample project (it has large assets)
Install
Choose one of two ways.
Clone the sample project
git clone https://github.com/WebAR-Studio/was-vps-unity.git
Open the project in Unity 2022.3 or newer. The scenes in Assets/Scenes show working setups.
Add with the Package Manager
- Open Window → Package Manager.
- Click + → Add package from Git URL….
- Paste
https://github.com/WebAR-Studio/was-vps-unity.git?path=/Assets.
Unity downloads the SDK into Packages/was-vps-unity.
Set up the scene
- Create or open a scene that is ready for AR Foundation. It needs an AR Session and an AR Session Origin.
- Add
VPSLocalisationServiceto an empty GameObject. This component runs localization. - In the Inspector, assign:
AR SessionAR Session Origin- the AR camera and UI hooks, if you need them (see the sample scenes)
- Enter your VPS API Key and at least one Location ID.
- Optional: while you debug, turn on Save Images Locally or Save Logs In File.
Need an API key?
Get one at arclip.design or email support@arclip.design.
Start localization
Control localization from your own script. Add the component below and assign the
VPSLocalisationService reference in the Inspector.
using UnityEngine;
using WASVPS;
public class VPSBootstrap : MonoBehaviour
{
[SerializeField] private VPSLocalisationService vpsService;
private void Start()
{
vpsService.OnPositionUpdated += HandlePositionUpdated;
vpsService.OnErrorHappend += HandleError;
var settings = new SettingsWASVPS(
new[] { "your-location-id" },
failsCountToReset: 5
);
settings.ApiKey = "your-api-key";
settings.LocalizationTimeout = 2.0f;
vpsService.StartVPS(settings);
}
private void HandlePositionUpdated(LocationState state)
{
Debug.Log($"Localized at {state.Localisation.VpsPosition}");
}
private void HandleError(ErrorInfo error)
{
Debug.LogError(error.LogDescription());
}
}
Inspector settings
| Property | What it does | Default |
|---|---|---|
| Start On Awake | Starts localization when the scene loads | false |
| Force Mock In Editor | Always uses the mock provider when you run in the Editor | true |
| Send GPS | Adds the device's GPS data to each VPS request | false |
| Fails Count To Reset | How many failures in a row reset the session | 5 |
| Save Images Locally | Saves captured frames for debugging | false |
Test and debug
- Turn on
Force Mock In Editorand use the included mock textures to test without a device. - Call
VPSLogger.SetLogLevel(LogLevel.VERBOSE)to see HTTP requests, responses and errors in the console. - If localization never succeeds, check that your API key is valid and that each location ID matches a VPS map you have.
Examples
- See
Assets/Scenes/TestScene.unityandAssets/Scripts/ExampleVPS.csin the sample project for working examples. - Use VPS poses in your own logic: spawn anchors, align 3D content or update the UI.
Next: Unity platforms — build for phones, headsets and glasses.