Why OnMouseDrag is not being called?

I am new in unity, i just creted an scene with an object on it, i added a js script to this object.

First i was trying to print a message on cosole when the object was clicked, and i found out that there is an event like this:

function OnMouseDown (){}

i put it on my code after the update function and it never was called. Finnaly this worked for me:

function Update () {
if (Input.GetMouseButtonDown(0)) {
Debug.Log(“clicked”);
}
}

Now i am trying to achieve the OnMouseDrag event, but it never gets called, why?

They are not the same thing.

The event OnMouseDown is an event that is called when… and i quote from the Documentation:

OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider.

If you haven’t satisfied that event, the event will be not raised.

Update is called very frame, you are checking the Input for the mouse button to be down, and as long as it is during the frame, the if block is executed.

For Future Ref
This works:

var myFPS: Transform;
var someBoolean : boolean = false;
var camPos: Vector3; 
var endPos: Vector3;
var time : float;
 


function Update () {
    Debug.Log ("nope");
if(someBoolean == true) {
    myFPS.transform.position.z = Mathf.Lerp(camera.main.transform.position.z, endPos.z, .5f * Time.deltaTime);
    Debug.Log ("true");
    //someBoolean = false;
}
}

	function OnMouseUp () {
    someBoolean = true;
    Debug.Log ("setTrue");
    }