I have an object that has a rotate script. I also have a GUI texture button that when is pressed a color picker appear. I want to disable the rotate function when my mouse is over the color picker.
I came up with this code which is not working.
This function is in the rotate script :
function isCameraInputIgnored () : boolean {
otherScript = Camera.main.GetComponent(colorPicker);
//should be true isf the color picker is present
var mousePos : Vector3 = Input.mousePosition;
// invert the y-coordinate
mousePos.y = Screen.height - mousePos.y;
if (otherScript.colorPickerPresent)
return true; //mouse is over color picker
return false; //if mouse isn't over
}
This function is in the color picker script :
static var colorPickerPresent = false;
static var colorPickerRect : Rect = Rect(820,190,150,150);
function Update(){
var mousePos : Vector3 = Input.mousePosition;
// invert the y-coordinate
mousePos.y = Screen.height - mousePos.y;
print(mousePos.y);
if (colorPickerRect.Contains(mousePos))
colorPickerPresent = true;
colorPickerPresent = false;
}