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!
[EDITED]
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) {
Debug.Log(test.HitTest(Input.mousePosition).name);
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.
Thanks for the response! Can I apply this to like guiTextures which is what I want to do without creating Rect()? Where my guiTexture is always available at the top of the screen
– anon66854890