mouse Down+Hold and double click events

I am trying to get an object to register different events based on click, double click and a hold event. Currently I can click and hold in the scene to move a camera (Great!) and I can double click an object to register a hit on the object (Great!) but I can’t click and hold on the object to to open a pop up (not so great.)

this is how I have been trying:

    private float lastClick = 0;
	private float waitTime = 1.0f; //wait time befor reacting
	private float downTime; //internal time from when the key is pressed
	private bool isHandled = false;


	//WIP: marking menu code. Find if the mouse is held in place for x amount of time with less than x amount of movement.
	//then stop the camera script and fire a script from OnMouseUp to call the markup and reactivate the camera
	void OnMouseDown () {
		//start recording the time when a key is pressed and held.
		downTime = Time.time;
		isHandled = false;

		//look for a double click
	    if(Time.time-lastClick < 0.3){
	    	
			// do something
			Debug.Log("You double clicked the target.")
			}
			//open a menu when the key has been held for long enough.
		}
		if((Time.time > downTime + waitTime) && !isHandled){
			isHandled = true;// reset the timer for the next button press
			//add markup menue script here.
			Debug.Log ("MouseKey was pressed and held for over " + waitTime + " secounds.");
		}
	    lastClick = Time.time;
	}

I can get the double click to work and have had the debug.log show up for the hold but its not timing it right and its not resetting. It would be great if I could also register the amount of mouse movement so if I click and move it still drags the camera rather than opening the menu.

maybe encompass the whole thing in something like:

if(Input.GetAxis("Mouse X") < transform * 0.5f; //?

any ideas?

I would use the OnMouseDrag() function which is called after OnMouseDown if the mouse button is still held down. OnMouseDrag is called regardless of the mouse being over the collider, so you may want to check that.

private float lastClick = 0;
private float waitTime = 1.0f; //wait time befor reacting
private float downTime; //internal time from when the key is pressed
private bool isHandled = false;


//WIP: marking menu code. Find if the mouse is held in place for x amount of time with less than x amount of movement.
//then stop the camera script and fire a script from OnMouseUp to call the markup and reactivate the camera
void OnMouseDown () {
	//start recording the time when a key is pressed and held.
	downTime = Time.time;
	isHandled = false;
	
	//look for a double click
	if(Time.time-lastClick < 0.3){
		// do something
		Debug.Log("You double clicked the target.");
	}

	lastClick = Time.time;
}

void OnMouseDrag(){
	//open a menu when the key has been held for long enough.
	if((Time.time > downTime + waitTime) && !isHandled){
		isHandled = true;// reset the timer for the next button press
		//add markup menue script here.
		Debug.Log ("MouseKey was pressed and held for over " + waitTime + " secounds.");
	}
}