Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
3.04k stars 1.14k forks source link

Need to destroy or restart ARTrackedImageManager? #1107

Open dorkbot opened 1 year ago

dorkbot commented 1 year ago

I have a scene with image tracking, it works. But when the app leaves this scene and loads another, then loads the image tracking scene again, the trackedImagesChanged action never returns objects in ARTrackedImagesChangedEventArgs.added again, it only has objects in ARTrackedImagesChangedEventArgs.updated, even after the scene reloads...

I've tried ARTrackedImageManager.subsystem.Destroy(); but that didn't change the issue. Also tried ARSession.Reset(), but still no luck.

How do I completely restart ARTrackedImageManager so when the scene loads it's fresh?

Thank you!

andyb-unity commented 1 year ago

This is how we do it in our sample app: https://github.com/Unity-Technologies/arfoundation-samples/blob/main/Assets/Scripts/Runtime/SceneUtility.cs

dorkbot commented 1 year ago

Thank you, but I attached that script to a GameObject in the scene and no luck. Once an image is added it is never added again after a scene is loaded. I have to quit the app to get a tracked image to get added again. Does that make sense? The data must be stored somewhere else? Some static ref somewhere...

andyb-unity commented 1 year ago

Hm. That seems like a bug to me if so. ARTrackedImageManager predates my time at Unity so I'm not sure what the issue is here. Flagging this as needs investigation to see if we can assign someone to look at this in a future sprint.

andyb-unity commented 1 year ago

@dorkbot What platform(s) / devices are you seeing this?

dorkbot commented 1 year ago

Hi, I'm using Unity 2022.3.7f1. And testing Android builds on a Pixel 6.

dorkbot commented 1 year ago

I suspect there is a similar issue when using ARPlaneManager. It appears that planes are stored so when the scene reloads it's using planes from the previous session. I'm not saying the issue is specifically with ARPlaneManager and ARTrackedImageManager, maybe it's a subsystem or something. My app has a two scenes that use one of each manager.

dorkbot commented 11 months ago

@andyb-unity Is there any update? I am having issues with Plane AR. In my app when I leave the AR Plane scene then return there are planes left from the previous session, the scene gets sorta polluted. Is there suppose to be a solution for clearing all planes?

andyb-unity commented 11 months ago

Do you have the same issue in our sample app? https://github.com/Unity-Technologies/arfoundation-samples

Personally I've never seen the issue you describe.

dorkbot commented 11 months ago

I guess I can try to create a test, but my scene is built exactly the same way and there's nothing I've done that would explain why detected planes from a previous scene load/session would be present. Or why ARTrackedImagesChangedEventArgs.update would have tracked info when a scene loads but not ARTrackedImagesChangedEventArgs.added. For both plane detection and image tracking, the scenes are loading with the previous session's data.

You guys are not able to recreate it?

:(

dorkbot commented 11 months ago

It's 100% of the time for me

MinasKatsiokalis commented 6 months ago

I solved whtis issue by createing a new ARTrackedImageManager component each time I load fresh my AR scene. Then, I set the referenceImage library with all the images I want to track.