/** *<summary> * Calls <see cref="IObjectControl.HoverOff"/> if pickedThisFrame and pickedLastFrame aren't the same *</summary> */ bool callHoverOff() { if (pickedLastFrame != pickedThisFrame && pickedLastFrame != null) { //Debug.Log("Calling HoverOff for " + pickedLastFrame); pickedLastFrame.HoverOff(); return(true); } return(false); }
void Update() { if (mousePick()) { //If the mouse is over not over the same object it was last frame //Calls HoverOff on the IObjectControl if (pickedLastFrame != pickedThisFrame && pickedLastFrame != null) { pickedLastFrame.HoverOff(); } //If the mouse is not over the object stored in clickedObject //Call mouseDown revert and set ignoreMouseUp to true if (pickedThisFrame != clickedObject && clickedObject != null) { clickedObject.MouseDownRevert(); ignoreMouseUp = true; clickedObject = null; } //If mouse click was released, calls mouseup on the IObjectControl // then sets clickedObject to null (since mouseButtonUp can't happen without mouseButtonDown first) if (Input.GetMouseButtonUp(0)) { //Ignore mouse up is set to true when //--while the mouse button is held down-- //clickedObject != pickedObject if (ignoreMouseUp) { ignoreMouseUp = false; return; } else { if (clickedObject != null) { Debug.Log("Sending mouseUp to " + clickedObject); clickedObject.MouseUp(); } else { Debug.LogError("ClickedObject == null"); } clickedObject = null; } } //If mouse is clicked, assign pickedThisFrame to clickedObject //Calls mouseDown on the associated IObjectControl if (Input.GetMouseButtonDown(0)) { clickedObject = pickedThisFrame; if (clickedObject != null) { clickedObject.MouseDown(); } else { Debug.LogError("ClickedObject == null"); } } //If when picked this frame is different than picked last frame, this is the first frame the object has been picked, so I call HoverOn if (pickedThisFrame != pickedLastFrame) { pickedThisFrame.HoverOn(); } } //Update pickedLastFrame pickedLastFrame = pickedThisFrame; }