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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With