UI buttons

Hi,
I’m having some problems with UI buttons.

void OnMouseDown()
{//this for grass tiles
	Debug.Log ("1b");
}

void OnMouseDown()
{//this for warrior (red)
	Debug.Log ("1");
}

When I click on my warrior (red) his OnMouseDown() is not called, instead grassButton’s script is executed. Does anyone know how to fix this?

Both grassButtons and Warrior are UIButtons instantiated via script.

You don’t use OnMouseDown for UI elements, you use the OnClick event of the Button or EventTrigger component, or implement the IPointerDownHandler interface.

This official Unity video shows the first and simplest method: http://unity3d.com/es/learn/tutorials/modules/beginner/ui/ui-button