Show/Hide Mouse on Screen Position

I've been looking for a way for some days now here in unityAnswers(but no luck yet) to show my cursor when it is at 20pixel from top of my screen and center and hide it when it is greater than 20pixel.

Any help is greatly appreciated! Thanks!


I just found a solution using the code from the Scripting manual and just added a couple of lines. Here it is if someone is interested.

private var test : GUILayer;

test = Camera.main.GetComponent(GUILayer);

function Update() {
if(test.HitTest(Input.mousePosition) != null) {
     Screen.showCursor = true;
} else {
     Screen.showCursor = false;


Put this code on your GUITexture. It should make your mouse cursor appear when it is hitting it. Just don't forget to apply the

Screen.showCursor = false;

on an empty GameObject or so.

You could define a rectangle in screen coordinates and use Rect.Contains to detect if the mouse is inside.