SpriteRenderer and OnMouseXX events... still work?

Dear All,

I’ve just found the new SpriteRenderer component and I Love it!! Thank you Unity3D.

My question regards tho the mouse clicks events. I attached them a script with the

void OnMouseUp(){
		Debug.Log("name 2: " + gameObject.name);
}

the gameObject with the SpriteRenderer has a boxCollider2D. Now, I noticed that the OnMouseUp is never called when I click on the sprite with the mouse.

Why? , Shall I use Physics2D.RayCastHit2D instead?

many thanks,
GC

Works fine here. Make sure the collider matches up with the sprite.

–Eric

Hi this is my configuration of the SpriteRender and the OnMouseUpAsButton function. But I was expenting the debug.log to print out the name of gameobject sprite, but nothing happens. :frowning:

Any Clue? Thank you for trying my previous snippet.

void OnMouseUpAsButton() {
		Debug.Log("name: " + gameObject.name);
		if (TestIOSorAndroid() == false) {//If I am not running 
			//Jump to the Info pannel.
			cameraNextPanel.gameObject.SetActive(true);
			infoPanel2Activate.gameObject.SetActive(true);

			//Only for the HOME button.
			if (currentCamera != null) {
				currentCamera.gameObject.SetActive(false);
			}

			//Disable current panel
 		    if (transform.parent != null){
				transform.parent.gameObject.SetActive(false);
			}
			
		}
	}

forgot the snapshot