Gui.Button over another gui.button

Hi! I have a gui.button and another second over him to cancel the action.
The problem is if I use this code:

	if(GUI.Button(Rect(30, 100, 70, 70), mainBut))
	{
	    Debug.Log("MAIN BUTTON");
	}
	if(GUI.Button (Rect(160,100,20,20), cancel))
	{
		Debug.Log("CANCEL");
	}

shows the cancel button but doesn’t work, and If I use this:

	if(GUI.Button (Rect(160,100,20,20), cancel))
	{
		Debug.Log("CANCEL");
	}
	if(GUI.Button(Rect(30, 100, 70, 70), mainBut))
	{
	    Debug.Log("MAIN BUTTON");
	}

the cancel button works but dont shows like the image(second) 22604-butt.png

Some ideas to fix this?

Thanks in advance! :smiley:

The coordinates you provide for your Rects in the code will not overlap like you have in your image. But here is a hack to solve your problem:

if(GUI.Button (Rect(160,100,20,20), cancel))
{
   Debug.Log("CANCEL");
}
if(GUI.Button(Rect(30, 100, 70, 70), mainBut))
{
    Debug.Log("MAIN BUTTON");
}
if(GUI.Button (Rect(160,100,20,20), cancel))
{
   Debug.Log("CANCEL");
}

A more involved solution would be to test the Rect of the cancel button. If you need code for this instead, let me know.