[Newbie] Simple Menu script c#

Hi! I’m a newbie in Unity and I want to make a simple menu script,i have watched/read some tutorials, but i don’t understand what the problem is. Here is the code:


     using UnityEngine;
        using System.Collections;
        
        public class Menu_Exit : MonoBehaviour
        {
        
        	
        	void OnMouseEnter()
        	{
        		renderer.material.color = Color.green;
        	}
        	
        	void OnMouseExit()
        	{
        		renderer.material.color = Color.black;
        	}
        	
        	void OnMouseDown()
        	{
        		Application.Quit();
        	}
        }

When i start the application, nothing works. No color change, the application doesn’t closes and I dont know why. Please help me
Thanks!

You can only change the color of an object if the shader supports it. Create a material with the standard ‘Diffuse’ shader (which than Default-Diffuse), and coloring changes will work. You may want to throw a directional light in the scene.

As for Application.Quit(), from the reference:

Quit is ignored in the editor or the
web player.

You can put a Debug.Log() inside OnMouseDown() to verify it is getting called. Note the object you have this script attached to must have a collider before any of the three callback will work.

[Question solved, adding this answer to remove it from the Unanswered list.]