using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class TestCShape : MonoBehaviour
{
    GraphicRaycaster RaycastInCanvas;

    // Start is called before the first frame update
    void Start()
    {
        RaycastInCanvas = GameObject.Find("Canvas").GetComponent<GraphicRaycaster>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            IsPointerOverGameObject();
        }

    }

    private void IsPointerOverGameObject()
    {

        PointerEventData eventData = new PointerEventData(EventSystem.current);
        eventData.pressPosition = Input.mousePosition;
        eventData.position = Input.mousePosition;
        List<RaycastResult> list = new List<RaycastResult>();
        RaycastInCanvas.Raycast(eventData, list);

        print(list.Count);
        for (int i = 0; i < list.Count; i++)
        {
            print(list[i].gameObject.name);
        }
    }
}
