Skip to content

Instantly share code, notes, and snippets.

Last active August 13, 2021 07:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Reacting to updated and removed tracked images in AR Foundation (part 2)
// Disable instantiated prefabs that are no longer being actively tracked
foreach (var trackedImage in eventArgs.updated) {
        .SetActive(trackedImage.trackingState == TrackingState.Tracking);
// Remove is called if the subsystem has given up looking for the trackable again.
// (If it's invisible, its tracking state would just go to limited initially).
// Note: ARCore doesn't seem to remove these at all; if it does, it would delete our child GameObject
// as well.
foreach (var trackedImage in eventArgs.removed) {
// Destroy the instance in the scene.
// Note: this code does not delete the ARTrackedImage parent, which was created
// by AR Foundation, is managed by it and should therefore also be deleted by AR Foundation.
// Also remove the instance from our array
// Alternative: do not destroy the instance, just set it inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment