Skip to Content
Quick StartUnity PackageTest in the Editor

Test in the Editor

Localization needs a real camera at a mapped place, so in Editor Play Mode the session simulates it instead. Only the camera frames and the VPS result are replaced. Everything else is the SDK’s normal code: state, map-root alignment, navigation, section transitions and automatic retry. Your scripts receive the same states and events as on a device, so you can build and test content, UI and navigation at your desk.

Simulate a session

Step 1 - Place the player

Move the XR Origin to where the player should stand in your authored scene. The camera starts there.

Step 2 - Start the session

Enter Play Mode and start the session as you normally would, with StartSession() or Start On Enable. The state is AwaitingInitial, as on a device waiting for a view it can match. Select the session and find the Editor simulation section at the bottom of its Inspector. If the session isn’t running yet, click Start session there.

Step 3 - Localize

Choose a section from the Section list (one entry per registered map root) and click Localize. The state goes through Guiding, with progress rising to 1, to Localized. The Localized event fires, and the section’s Authored content appears exactly where you authored it.

Step 4 - Navigate and walk

Once the section’s navigation data loads, choose a Destination and click Navigate, or start navigation from your own UI with StartNavigationAsync. Then click Walk route. The camera walks the route at the chosen Walk speed, keeping its height above the route, until NavigationArrived fires or the route reaches a section transition.

You can also move the camera yourself in the Scene view; navigation follows it.

Other controls

ControlWhat it does
Fail attemptBefore the first fix, fails the attempt with VpsAllAttemptsFailed, so you can test your failure handling. With Auto Retry Localization on, the next attempt starts after the usual backoff, as on a device.
Stop navigationCalls StopNavigation(); NavigationStopped fires.
Continue after transitionShown at a section transition. Calls ContinueAfterTransition(), which starts an attempt in the next section. Localize there to continue the journey.
Stop walkingStops the scripted walk.

What is not simulated

  • Camera and location permissions, tracking loss and drift corrections.
  • The network. SDK settings and navigation data still load from Graffity with your Project Settings token, so navigation needs a connection.

Simulated sessions send no analytics to Graffity. A LogClient you set in code still receives records.

Turn simulation off

Simulation is on by default. To run the device pipeline in the Editor instead, select the session in Edit Mode and clear Simulate in Play Mode under Editor simulation. The setting is yours alone: it is stored in the project’s UserSettings folder, not in the scene. It is read when the session initializes, and it never applies outside Play Mode or in player builds.

Drive the simulation from your Play Mode tests

The session has the same controls as methods, so an automated Play Mode test can run a whole journey and check what your own code does:

ArrivalTests.cs
using System.Collections; using Graffity.ARCloud; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; public sealed class ArrivalTests { [UnityTest] public IEnumerator ArrivalShowsTheRewardPanel() { // Load your scene first, for example with SceneManager.LoadScene. var session = Object.FindFirstObjectByType<GraffityARCloudSession>(); var lobby = Object.FindFirstObjectByType<GraffityARMapRoot>(); session.StartSession(); Assume.That(session.IsSimulated, "Turn on Simulate in Play Mode."); yield return new WaitUntil(() => session.CanSimulateLocalization); session.SimulateLocalization(lobby); yield return new WaitUntil(() => session.State.Vps.Kind == GraffityARVpsStateKind.Localized); yield return new WaitUntil(() => session.AvailableDestinations.Count > 0); var navigation = session.StartNavigationAsync(session.AvailableDestinations[0]); yield return new WaitUntil(() => navigation.IsCompleted); yield return new WaitUntil(() => session.CanStartSimulatedWalk); session.StartSimulatedWalk(5); yield return new WaitUntil(() => !session.IsSimulatedWalkActive); var rewardPanel = GameObject.Find("Reward Panel"); // your own UI Assert.That(rewardPanel != null && rewardPanel.activeSelf, Is.True); } }
MemberDescription
IsSimulatedTrue from initialization to shutdown in Editor Play Mode while Simulate in Play Mode is on. Always false in players.
CanSimulateLocalizationSimulateLocalization can apply now: the session is running, its settings have loaded and no transition or failure is pending.
SimulateLocalization(root)Localizes in the root’s section, with the root where you authored it. Before the first fix the state goes through Guiding to Localized over about a second. Returns false when the session can’t take a fix yet.
SimulateLocalizationFailure()Fails the waiting attempt with VpsAllAttemptsFailed. Returns false once localized.
CanStartSimulatedWalkNavigation has a route to walk.
StartSimulatedWalk(metersPerSecond = 1.4f)Walks the camera along the route, keeping its height, until arrival, a section transition or a stop. Returns false without a route.
StopSimulatedWalk()Stops the walk. The camera stays where it is.
IsSimulatedWalkActiveA walk is moving the camera.

Every method throws InvalidOperationException while IsSimulated is false, so call them only from Editor tests. There is no switch for Simulate in Play Mode in code; it belongs to each developer. Check IsSimulated in your tests, as the example does with Assume.