-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Describe the bug
ARTrackedImageManager.trackedImagesChanged reports incorrect XRReferenceImage when utilising a MutableRuntimeReferenceImageLibrary with images downloaded at runtime.
Steps to reproduce the behavior
The situation is a bit complicated, but my layout is as such:
- At runtime, I create a MutableRuntimeReferenceImageLibrary and populate it with downloaded textures using ScheduleAddImageWithValidationJob.
- I then create a new SimulatedARTrackedImage for each image in the library
This all works great! The SimulatedARTrackedImages show up in the scene and inspector and display the correct images.
- I then subscribe to ARTrackedImageManager.trackedImagesChanged and wait for an image to be added, updated or removed.
Expected behavior
When the SimulatedARTrackedImage appears in the Camera's view, the trackedImagesChanged event will run with the correct Trackable and XRReferenceImage in the added/updated lists.
Actual behavior
The trackedImagesChanged event runs, passes the correct Trackable, but the internal referenceImage (XRReferenceImage) stored in it is incorrect (it's always the same XRReferenceImage - potentially the first in the database but I've not verified it)
I believe I have been able to narrow it down to ARSimulationImageTrackingSubsystem's TryFindInLibrary method. TryFindInLibrary utilises AssetDatabase.TryGetGUIDAndLocalFileIdentifier but the Texture2D does not exist in the AssetDatabase.
The Unity docs for XRReferenceImage are quite outdated as they only talk about using a Texture2D that already exists in the AssetDatabase. The TextureGUID appears to be the issue here as that's always 00000000-0000-0000-0000-000000000000.
Versions (please complete the following information):
- Unity 2020.3.23f1
- ARFoundation 4.2.3
- OS: Windows 11
- ARSimulation 1.3.7