using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;

public class HandleImageTracking : MonoBehaviour
{
    [SerializeField]
    ARTrackedImageManager m_TrackedImageManager;
    public GameObject cube;
    private MeshRenderer _meshRenderer;
    
    void Start()
    {
        
    }
    
    void OnEnable() => m_TrackedImageManager.trackedImagesChanged += OnChanged;

    void OnDisable() => m_TrackedImageManager.trackedImagesChanged -= OnChanged;

    void OnChanged(ARTrackedImagesChangedEventArgs eventArgs)
    {
        foreach (var newImage in eventArgs.added)
        {
            cube.transform.position = newImage.transform.position;
        }

        foreach (var updatedImage in eventArgs.updated)
        {
            cube.transform.position = updatedImage.transform.position;
        }

        foreach (var removedImage in eventArgs.removed)
        {
            // Handle removed event
        }
    }
}