Rotating object with GUI Elements present

I have a house that has a rotate script attached. I also have 2 gui texture above the house and a color picker that appears whel one of the above buttons are selected. i want to disable the rotate function if the mouse is over any of the gui elements.


We do this by writing a function in the GUI script that returns a boolean indicating whether or not orbit input should be ignored. This function is easy to write: it gets the mouse position and checks whether or not it is inside the rectangle of any of our GUI controls (using Rect.Contains).

The camera control script calls this function at the beginning of its Update function. If guiController.isCameraInputIgnored() returns true, the Update function is exitted without processing any input.

The easiest way to get the scripts to play together is to declare an object in your camera control script that is of the same type as your GUI script.

In other words, if your GUI script is in a file named MyAwesomeGUI.js you would add the following to your camera script:

/* declare a variable that represents your gui script */

var guiController  :  MyAwesomeGUI;

function Update ()
    /* only do this if the guiController var has been assigned */

    if ( guiController != null ) {

        if ( guiController.isCameraInputIgnored() ) {

    /* add orbit code here */

I'm sure there are a trillion other ways to do it....

Just to be thorough, here's a simple example of a function named isCameraInputIgnored in a sample script:

/* example implementation of MyAwesomeGUI.js */

var playButtonRect    :  Rect  =  Rect(0, 0, 100, 40);
var quitButtonRect    :  Rect  =  Rect(0, 40, 100, 40);

/* return true if orbit input should be ignored */

function isCameraInputIgnored () : boolean
    var mousePos : Vector3 = Input.mousePosition;

    /* invert the y-coordinate */

    mousePos.y = Screen.height - mousePos.y;

    if ( playButtonRect.Contains(mousePos) ) {
        return true;

    if ( quitButtonRect.Contains(mousePos) ) {
        return true;

    return false;

i will try this on monday and come back with the result.
thanks in advance.

Mouse Orbit is the script behind the camera and tilesButtonClick is the script behind all my 7 buttons. i’ve added :
var guiController : tilesButtonClick; to my MouseOrbit.js
isCameraInputIgnored () function to tilesButtonClick.js
but i get an error : “The name “tilesButtonClick” does not denote a valid type.”
ideas ?