Hi,
I am working on an image tracking project which allow users dynamically add their existing photo as reference images.
Now the problem is I can’t trigger eventArgs.added in Unity’s Play mode. It seems only images in the serializedLibrary(ReferenceImageLibrary) works in the XR Simulation, but it is something I don’t want to have in this project.
So, is there anyway to simulate MutableRuntimeReferenceImageLibrary in Unity’s Play mode? Debugging through wireless connection(Logcat) is really painful.
Thanks in advance!
I find this: [5.1.0-pre.3] - 2023-02-06: Added support for mutable runtime reference image libraries to XR Simulation.
There is also such info in the docs:
XR Simulation can detect and track all simulated tracked images in an environment, even if you have not included their textures in your reference image library. To optionally bind a simulated tracked image to your reference image library, set the Image field of its Simulated Tracked Image component to reference a texture asset that is also used in the reference image library.
When XR Simulation detects images that are not part of the reference image library, the corresponding ARTrackedImage trackables will not contain a fully initialized referenceImage. Instead, the
guid
property of the referenceImage is set to zero, and itstexture
is set tonull
There is BasicImageTracking Example Scene that uses Mutable Library in AR Foundation Samples that I just tested.
I duplicated the simulated environment, added one more tracked image on the scene and set the Image
field as it mentioned before. I also added this in the protected override void OnTrackablesChanged()
of ARTrackedImageManager.cs
:
foreach (var newImage in added)
{
Debug.Log(newImage.referenceImage.guid);
}
Indeed, there is no reaction to added
list when a new image added to the library.
However, you can use updated
list, which can trigger perfectly and track the first appearance after adding an image to the library:
foreach (var newImage in updated)
{
Debug.Log(newImage.referenceImage.guid);
}
I can explain such behavior based on my research about Image Tracking:
possibly, the simulated environment assumes that AR Image is static in the environment, so once it appears in the camera view, it marks as static once because this is not a separate image - this is a container for image (SimulatedTrackedImage.cs
) which is not moving.
So, if you want to trigger added
list you need to add a new SimulatedTrackedImage.cs into the camera view: you can just place it before the scene start at some distance to the right/to the left from camera view.
It works! Thank you so much <3
Can you describe your case in more details: How exactly user add new Tracked Images and what the purpose of the App?