I am trying to figure how to utilize double-clicking to get things to happen. I want single-clicking to do one thing, double-clicking to do another, and double-click-and-holding to do yet another. I assume this will involve creative scripting using time differences, but I am a total novice at this. Thanks for any advice!
var doubleclickTime : float = .5;
private var clickTime : float = -999;
private var doubleclicked = false;
function OnMouseDown () {
if (Time.time < clickTime + doubleclickTime !doubleclicked) {
doubleclicked = true;
}
else {
print ("Click!");
doubleclicked = false;
}
}
function OnMouseUp () {
clickTime = Time.time;
if (doubleclicked) {
print ("Doubleclick!");
}
}
You might want different logic depending on what sort of behavior you’re after exactly. I think that code mimics clicking behavior in the Finder, whereas a website works differently (clicks register on mouseup instead). There’s also an OnMouseDrag function that might be useful, though I don’t know if you’re using OnMouse at all.