Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with OnMouseDown() event Unity

Tags:

c#

unity3d

I am new to Unity and I am doing some tutorials, but one drove me crazy. I have a rotating cube with a box collider on it. All events work except OnMouseDown(). I don't know what is the problem... Here is a snippet of code.

void onMouseDown() {        
    Debug.Log ("On Mouse Down Event!!!!!!!!!");
}

void OnMouseUp() {
    Debug.Log("On Mouse Up Event");
}

void OnMouseOver() {
    Debug.Log("On Mouse Over Event");
}

void OnMouseEnter() {
    Debug.Log("On Mouse Enter Event");
}

void OnMouseDrag() {
    Debug.Log("On Mouse Drag Event");
}

In the console, the message "On Mouse Down Event!!!!!!!!!" doesn't appear not matter my great number of clicks on the cube.

like image 305
ahsoka Avatar asked Dec 05 '22 11:12

ahsoka


1 Answers

void OnMouseDown() 
{        
    Debug.Log("On Mouse Down Event!!!!!!!!!");
}

Your OnMouseDown method needs to be written with a capital O, not a lower case one. Try that and it should work.

like image 107
Steven Mills Avatar answered Dec 13 '22 05:12

Steven Mills