OnMouse Events don't work with 2D spriterenderer

Hi guys.

I’m new to unity, and i have a question.

I have a GameObject with SpriteRenderer Component. I want to do something when mouse enter / leave this sprite. So, I added new script, something like this:

    void OnMouseEnter()
	{
		
		Debug.Log ("Tadaaa!");
	}

	void OnMouseExit()
	{
	
		Debug.Log ("yahooo!");
	}

But seems like it doesn’t work.

Not sure, but maybe I can’t detect mouse events without something like collider?

Yes, you need a collider. You should read the documentation if something is not working how you think it should. You will find out if its something like that alot faster that way

OnMouseEnter is called when the mouse entered the GUIElement or Collider.
1