using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;

public class Dummy : MonoBehaviour, IPointerDownHandler
{
    Despawn despawn ;
    void Start()
    {
        AddPhysics2DRaycaster();
        despawn = gameObject.GetComponent<Despawn>() ;
    }
    
    public void OnPointerDown(PointerEventData eventData)
    {
        despawn.InvokeDespawnEvent() ;
        Destroy(gameObject) ;
    }

    private void AddPhysics2DRaycaster()
    {
        Physics2DRaycaster physicsRaycaster = FindObjectOfType<Physics2DRaycaster>();
        if (physicsRaycaster == null)
        {
            Camera.main.gameObject.AddComponent<Physics2DRaycaster>();
        }
    }
}
