OnMouseDown doesn't work with Sprite

Hi, i have a sprite Game object (Sprite Renderer + Box Collider 2D + a script)

Here my script:

public class COBaseClickInput : MonoBehaviour {

	// Use this for initialization
	void Start () {
		Debug.Log ("Start");
	}

	void OnMouseDown () {
		Debug.Log ("Test!");
	}
	void OnMouseUp () {
		Debug.Log ("Test!");
	}
	void OnMouseOver () {
		Debug.Log ("Test!");
	}

}

When i start the game, i see the “Start” debug but if i move my mouse on the object and/or click it, nothing happens

Thank

I came across this question when running into a similar issue. In my case what fixed the problem was moving the centre of my box collider FURTHER from the camera. When it was 1 meter away it was not registering my clicks at all, but when it was 50 meters away it worked just fine.

Your script works fine; make sure the box collider matches up with the sprite (perhaps you have it offset or something).

It seems like the same issue as here: http://answers.unity3d.com/questions/587637/replacing-onmouseenterexitdownetc-with-raycasting.html

There’s a problem with multiple cameras and one being Orthographic, or something. If you’re using NGUI, you can use the events here instead - http://www.tasharen.com/?page_id=160

Check your scene, you may have other Collider2D’s closer to your camera than the one you want mouse events for.

I had an issue where a BoxCollider2D marked as ‘Is Trigger’ was closer to the camera when compared with the BoxCollider2D that I wanted mouse events for. If those two BoxCollider2D’s intersected at all, then the mouse events for the more distant collider didn’t fire.

NOTE: I didn’t test whether ‘Is Trigger’ is a requirement or not. I just moved those objects behind my sprite buttons and everything was fine.

HINT: When you are running the game and encounter the problem just look in your scene view and turn off the ‘2D’ toggle. You can then rotate your camera in 3D and the colliders will show up in green

i had a button with working OnMouseDown and suddenly stop working. i moved the button to a bottom layer and the backgroud was over it.