using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.UI;

public class UIBackground : MonoBehaviour
{
    public static List<UIBackground> uiBackgroundQueue = new List<UIBackground>();

    public Image BackgroundImage { get; private set; }
    public Canvas UICanvas { get => GetComponentInParent<Canvas>()?.rootCanvas; }
    public VertexHelper vertexHelp { get; set; }
    public Mesh mesh { get; set; }

    public bool DirtyMesh = true;
    public Camera MainCamera;

    private void Awake()
    {
        BackgroundImage = GetComponent<Image>();
    }

    private void OnEnable()
    {
        BackgroundImage.enabled = false;
        uiBackgroundQueue.Add(this);
        DirtyMesh = true;
    }

    private void OnDisable()
    {
        BackgroundImage.enabled = true;
        uiBackgroundQueue.Remove(this);
    }
}