x


How to hide the cursor

Hello,

I want to hide the cursor as I am using a gamepad instead of mouse and keyboard.

Would this code work for that:

Screen.showCursor = false;

and if so where show it go?

I am really new, and have no experience coding (dont really know how i made it this far)

Cheers,

Sabrina

more ▼

asked Nov 11 '10 at 01:49 AM

Sabrina gravatar image

Sabrina
47 5 5 12

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

If you want to hide the cursor through the entire game you should add the "Screen.showCursor = false"-code inside the Start function ;)

like so:

void Start ()
{
    Screen.showCursor = false;
}

(in C#)

or:

function Start ()
    {
        Screen.showCursor = false;
    }

(in JavaScript)

more ▼

answered Nov 11 '10 at 11:27 AM

Yoerick gravatar image

Yoerick
729 2 5 14

(comments are locked)
10|3000 characters needed characters left

ive never coded can some one tell me where to add this script or how to please

more ▼

answered Dec 23 '12 at 10:33 AM

BearMan11 gravatar image

BearMan11
16

Mar 12 at 12:11 PM yu-gi-master

Here is code to hide/show mouse with an explanation:

    var showingMouse : boolean;//for checking if mouse is shown or not

    function Start(){
    showingMouse = false;
    Screen.showCursor = false;
    Screen.lockCursor = true;
    }

//executed every frame
    function Update(){

    //if you press "r"  and the mouse is not shown then the mouse is shown and movable then execute code
    if(Input.GetKeyDown(KeyCode.R) && showingMouse == false){
    showingMouse = true;
    Screen.showCursor =true;
    Screen.lockCursor = false;
    }
    //if you press "r" and the mouse is shown then make it not shown
    else if(Input.GetKeyDown(KeyCode.R) && showingMouse == true){
    showingMouse = false;
    Screen.showCursor =false;
    Screen.lockCursor = true;
    }

    }
Mar 12 at 01:27 PM DynamicPrgm
(comments are locked)
10|3000 characters needed characters left

If you also want to hide the cursor AND lock it in the center of the screen, you should use

Screen.lockCursor = true;

more ▼

answered Dec 27 '10 at 02:01 AM

Al Anselmo gravatar image

Al Anselmo
62 4 5 10

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x198
x3

asked: Nov 11 '10 at 01:49 AM

Seen: 6009 times

Last Updated: Mar 12 at 01:27 PM