Testing of Mutable Runtime Reference Image Library in Unity Editor: XR Simulation + AR Foundation

MutableRuntimeReferenceImageLibrary is intended to add Images for Tracking on the go when the user has running app on his phone.

Using AR Foundation 5.1.0+ and the next tips, you can test the Adding of New Images into the Mutable Library in the Runtime correctly with XR Simulation.

This is a Video Demo on How to test Mutable Runtime Reference Image Library correctly in Unity based on my Text Tutorial.

Demo Scene to Test

There is BasicImageTracking Example Scene that uses Mutable Library in AR Foundation Samples, and I:

  1. Duplicated the Simulated Environment by Default: Window > XR > AR Foundation > XR Environment > XR Environment overlay > Pencil icon > Duplicate Environment.
  2. Added one more Tracked Image next to the existing one on the Scene and set the Image field of its Simulated Tracked Image component for All Images: to bind a simulated tracked image to your reference image library.
  3. Added the next parts of code in the OnTrackablesChanged() method of ARTrackedImageManager.cs.

2 Approaches to Test

You can test the Adding of New Image in Runtime using 2 predefined lists.

  1. added list

foreach (var newImage in added)
{
    Debug.Log("added >: " + newImage.referenceImage.guid);
}

There is no reaction to added list when a new image added to the library during runtime because all Simulated Tracked Images were in the Camera View at start.

The Simulated Environment assumes that AR Image is static in the environment, so once it appears in the camera view, it marks as static because this is not a separate image — this is a container for an image (SimulatedTrackedImage.cs) which is not moving.

To trigger added list, you just need to add a new SimulatedTrackedImage.cs into the camera view: you can just place the SimulatedTrackedImage Game Objects before the Scene Start at some distance to the right/to the left from the Camera View.

This method will not work for true testing goals:

Scene View > open Duplicated Simulation Environment prefab to observe camera position > root Game Object > Simulation Environment component > Camera Starting Pose > Rotation/Position.

  1. updated list

foreach (var newImage in updated)
{
    Debug.Log("updated: " + newImage.referenceImage.guid);
}

It can trigger perfectly for Added Image in Runtime and you can track the first appearance after adding an image to the library.

Resources

  1. Complete AR Testing Tutorial.
  2. My AR Assets.