So sometimes you are going along making a Unity3D game and you need to check to see if the player is executing a click and drag motion. But you also want to make sure that click+drag action is distinguished from a single click. Well I have a C# solution to this problem. Its also easy enough to convert to Javascript if thats how you roll. And if you use Boo...well why the hell are you using boo?


 bool mouseDragging = false;  
 bool mouseDraggingLastFrame = false;  
 Vector3 mousePosLastFrame;  
   
 bool MouseDragging() {  
      if(mouseDraggingLastFrame == true)  
           mouseDragging = true;  
      else   
           mouseDragging = false;  
   
      if(Input.GetMouseButton(0) && mousePosLastFrame != Input.mousePosition) {  
           mouseDraggingLastFrame = true;  
      } else {  
           mouseDraggingLastFrame = false;  
           mouseDragging = false;  
      }  
      mousePosLastFrame = Input.mousePosition;  
      return mouseDragging;  
 }  

This function will return true if the mouse is executing a click drag motion. But it needs to be called from within the Update method.

I'm done now.