OnMouseEnter to a GUITexture with transparent regions

Assume that we have a texture file with transparent regions (See attached GUIQuestion.PNG file) and it is assiged to a GUI Texture object.
If we attached the following code to GUI Texture object, Unity calls OnMouseEnter even if mouse is in the transparent region of the texture.

How to use GUI Texture object so that it can only detect the mouse when mouse is over the non-transparent region of the texture?

function OnMouseEnter () { 
   Debug.Log("OnMouseEnter"); 
}

function OnMouseExit(){
  Debug.Log("OnMouseExit"); 
}
 
function OnMouseDown(){ 
   Debug.Log("OnMouseDown"); 
}

function OnMouseUp(){
   Debug.Log("OnMouseUp"); 
}

i cant tell u for ur tex but there are ways to make it round so for example if mouse enters the small circle in the middle…

For the big one it works too but the cutouts would be true too…

Maybe anyone can correct my code?

Put to ur code

Var hover = false; // is the mouse over?
Var point Vector2 = new Vector2(10,10);// the midllepoint of ur tex

var radius = 20f;//radians from the middlepoint

function Update () {

var disx = point.x - Input.mousePosition.x;//x distance
Var disy = point.y - (Screen.height - Input.mousePosition.y);//y distance, mouseposition is from lower left rect from upperleft, thats why the subtraction
// now to the sentence of pythagoras

var endx = Math.exp(disx);
var endy = Math.exp(disy);

//finally get the end product
Var finaldis = Math.sqrt(endx + endy);

//check if in the range
if(finaldis <= radius){

hover = true;

}
else {

hover = false;

}
}

PS: for the circle left out u can use sinus and cosinus but i think u have to rotate the tex a bit then…

Dear Robbilie,

Thank you for your explanation. It is certainly useful.

However, I was wondering if Unity has a build-in function to detect if mouse entered/exited/down/up on a non-transparent region of a GUI texture.
I do not know how to do it, but, a generic solution of this problem would be checking the alpha value (transparency) of the texture at the cursor position. If it is not transparent then activate the OnMouseEnter etc.

Adding to that, you could check the alpha value of the pixel in the OnMouseOver() function, since it’s called every frame and not just when the mouse enters the Rect?