Closed Tolo789 closed 2 years ago
You should never destroy the GameObject that wraps the trackables. Some trackables are manually removable (ie RemoveAnchor for the ARAnchorManager) but not all trackables are removable. If you want to stop acting on some trackables you should use arGameObject.SetActive(false).
Some more documentation on trackable lifecycle
Hi @DavidMohrhardt,
Thank you for your reply, indeed my title is too generic since some ARTrackableManager
do support manual delete of trackables.. But how about the ones that don't?
As mentioned, I'd like to be able to "rediscover" some planes/pointClouds and simply using SetActive(false)
as you suggest isn't enough: it simply hides (and stop updating) the trackable, but it doesn't mean that a new one will be crated for the very same plane/pointCloud.. And if I enable back the stopped one (with SetActive(true)
) the trackable data will instantly match the values of when I've stopped it, while I'd like it to reset as if it was just created instead.
Maybe I'm not clear enough on what my goal is, so I'll try with a more practical example:
ARPlaneManager
To get this desired effect the only solution I've found so far is to destroy the ARPlaneManager and create a new one, but maybe there is a better way to handle this?
Hi @Tolo789
The solution you discovered for this case is indeed correct! On both iOS and Android, AR Foundation's behavior is to preserve the state of discovered trackables if their Manager is disabled, so that they can be restored if the Manager is enabled again.
The only supported way to "restart" plane discovery as you say, is to destroy the ARPlaneManager
and recreate a new one. Admittedly our docs are a bit sparse on this topic, so I've made a note to see if we can include this information in the future.
Hi, I'd like to be able to "reset" an
ARPointCloudManager
and anARPlaneManager
so that all gathered data about the surrounding environment is cleared and thetrackables
found so far are destroyed, thoseARTrackableManager
should stay enabled though and will then behave as if we just started them for the first time.I've looked around a bit and didn't find any method to do so, I've noticed that doing a
ARSession.Reset
works but it forces both managers to be reset at the same time whereas I want to be able to only reset one of the two based on some logic of my code. Another thing that I've tried is to destroy the trackables gameobject by hand, but I get plenty of errors afterwards.So what I ended up doing is to destroy the
ARPointCloudManager
/ARPlaneManager
and recreate a new one right afterwards, which gives exactly the behaviour that I was looking for.. However it feels a little dirty to do so, I was wondering if there is a cleaner way to do this?