Double Click

hey all

I know this subject is discussed many times, but im actually not finding my answer, so i decided to post this.

i’m writing a script to detect the doubleClick of a mouse inside the Update() function
so far i have reached this

protected float doubleClickDelay = 0.2f,previousClick = 0f;
void Update(){
//.....
if(Input.GetMouseButtonDown(0) ){
			float gap = Time.time - previousClick;
			if( gap < doubleClickDelay ){
				Debug.Log("DC");
			}else{
				Debug.Log("not DC");
				detectObjectSelection();
			}
			previousClick = Time.time;
			
		}
//....

when im debugging it, the mouse actually detects the double Click, but here is the problem
when im single clicking, i get “notDC”
when im double clicking , i get “not DC” and “DC”

the first click is always accessible in the script whether its one/two clicks :confused:
I cant use this script inside the onGUI() function, therefore i cant use the Event class to detect the .clickCount.

my question is how to eliminate the “notDC” in the double Clicking ?

you can’t… that’s how it is. The first click in the double click will be a single click, the second the double click.

The single click doesn’t know the future.

Your only other option is to not fire single click until after the duration it waits to check for a double… and if no double occurs, THEN act like a single.

But that’s going to make mouse clicks feel sluggish.

thx for the fast reply!
i already though about this workaround but i dont want the sluggy feel of the selection, thats why I posted this :S

Well it’s really your only option. The computer can’t tell the future of what the user will do.