OnMouseOver doesn't work

I am creating 2d game.
I want to be notified when an object is clicked. Here is my code

    	public void OnMouseOver()
    	{
    		Debug.Log ("mouse over block");
    		if(Input.GetMouseButton(0))
    		{
    			Debug.Log ("clicked");
    		}
    	}

I never get the log message even when i am hovering over the object.
The object has box2d collider.
I am using NGUI. Could that be causing the issue?

I have 2 cameras, both Orthographic but i swear it was working before.

Thanks

The GameObject you want to hover over needs to contain the script that contains your code. It also cannot belong to the Ignore Raycast layer.

Also you should format your code so it’s easier to read with ctrl+k.

this script should work anywhere you are using it.just make sure there is a collider on the object being clicked.

 var clicked:GameObject;
 var hit:RaycastHit; 
 var clickray = Camera.main.ScreenPointToRay (Input.mousePosition);
    		
            if(Input.GetMouseButtonDown(1)){ 
             if (Physics.Raycast(clickray, hit)) {
                clicked = hit.collider.gameObject;}}

If the script is attached to the gameobject being clicked, I beleive you can just simply use Onmouseover like this:

	function OnMouseOver () {
         print("mouse is looking at me");
	}

Try moving your object into an area where there is nothing behind or in front to test it .

Sometimes depending on your rendering or sorting layer, it might look like your object is in front of the background, but unity sometimes will detect the background first, and OnMouseOver won’t register.