[RequireComponent(typeof(PolygonCollider2D))]
public class IrregularImage : Image
{
    private PolygonCollider2D m_polygon;
    private PolygonCollider2D Polygon
    {
        get
        {
            if (m_polygon == null)
            {
                m_polygon = GetComponent<PolygonCollider2D>();
            }
            return m_polygon;
        }
    }

    //PolygonCollider2D需要自己在面板上自己编辑,或用代码编辑
    public override bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera)
    {
        RectTransformUtility.ScreenPointToWorldPointInRectangle(rectTransform, screenPoint, eventCamera, out Vector3 worldPoint);
        return Polygon.OverlapPoint(worldPoint); //这个方法用来判断坐标点是否在collider范围内
    }
}