Detect click only on not transparent part of button

How do I detect click on button that don’t have rectangle graphics?
Let’s say my button looks like upside-down L:

I want button to activate only when pointer is over green part of image and ignore transparent part in lower right corner.

I looked up and found this guy with same problem here, so I tried using “Image.alphaHitTestMinimumThreshold” (which sounds like perfect solution for my problem) but it seems that it no longer works (‘Image’ does not contain a definition for it).
So… how do I do it?

You could get the localRect coordinate and change that to a percentage and use the percentage to get the pixel color in the texture. Just make sure the texture is read/write enabled. The code below will do it… I think… might need to play with the x and y positions a little. And definitely will need to set the pivot point to the bottom left corner (0,0).

    public RectTransform but;
    public Texture2D tex;
    
    public void OnButtonPressed()
    {
        Vector2 pos = new Vector2();
        Vector2 mouse = EventSystem.current.currentInputModule.input.mousePosition;
        RectTransformUtility.ScreenPointToLocalPointInRectangle(but,mouse , null, out pos);

        float px = pos.x / but.rect.width;
        float py = pos.y / but.rect.height;

        float tx = px * tex.width;
        float ty = py * tex.height;

        Color col = tex.GetPixel((int)tx, (int)ty);
    }

Even I was facing the same problem and figured out a solution for this:

1)For the button or the Image you are keen about uncheck RayCast Target

2)Add another button which will cover exactly that portion of the area where you want you click to be happening

3)Make it a child of the 1st Button

4)In the inspector pannel ,under color make sure that value of A=0 to make it transparent

5)Now whatever onClick operation you want to perform do it there,