This might be a bug, or I may just be looking at this wrong, but here's the behavior I'm seeing. I want to be able to click the mouse somewhere on the screen (not over my target) and drag the mouse over the target object. When I let go of the mouse button, I'd like things to happen. On my target object I have a script attached with this:
function OnMouseUp() {
print("Your Mouse button is up!");
}
Pretty simple. Yet, when I click somewhere on the screen, drag my mouse on top of the object, and then let the button go nothing happens. If I click the mouse down on top of my target and then let it go it works correctly. I assume this is because when my mouse is clicked while over the target it fires the OnMouseDown() function.
I've worked around the issue by setting a variable to true when OnMouseEnter() is triggered, and then in the update() I test is the variable is true && the GetMouseButtonUp(0).
function OnMouseEnter() {
mouseIsOver = true;
}
function Update() {
if(mouseIsOver) {
if(Input.GetMouseButtonUp(0)) {
print("Your mouse button is up!");
}
}
}
Is this a bug, or am I missing something really obvious?