Problems with simple cube click

I created “main script” and in Start() created simple Cube:

GameObject cube =
GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.localScale = new
Vector3 (1,2,1);
cube.GetComponent().material.color
= new Color(0,0,255); cube.Addcomponent();

and than in CubeScript I have empty Start() and Update() but just your OnMouseDown with

Debug.Log(“click detected”);

and I can never see logs despite clicking on cube… Any advice? did I missed something?

Works for me, check syntax? Are you altering any colliders somewhere? http://i.imgur.com/UgYj4lM.gif

using UnityEngine;
using System.Collections;

public class cubeScript : MonoBehaviour {

    void OnMouseDown()
    {
        Debug.Log("click");
    }
}


using UnityEngine;
using System.Collections;

public class makeCube : MonoBehaviour {

	// Use this for initialization
	void Start () {
        GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        cube.transform.localScale = new Vector3(1, 2, 1);
        cube.AddComponent<cubeScript>();
	}
}