Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by Sabrina · Nov 11, 2010 at 01:49 AM · cursor

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

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Spy4812 · Aug 29, 2013 at 07:24 PM 0
Share

hello I have made a menu in unity and need to implement this code into it void Start () { Screen.showCursor = false; }

I need to put it in this:

 void Start ()
 {
     Screen.showCursor = false;
 }
 using UnityEngine;
 using System.Collections;
 
 public class pause$$anonymous$$enu : $$anonymous$$onoBehaviour 
 {
     public GUISkin myskin;
 
     private Rect windowRect;
     private bool paused = false , waited = true;
 
     private void Start()
     {
         windowRect = new Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 200);
     }
 
     private void waiting()
     {
         waited = true;
     }
 
     private void Update()
     {
         if (waited)
             if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.Escape) || Input.Get$$anonymous$$ey($$anonymous$$eyCode.P))
             {
                 if (paused)
                     paused = false;
                 else
                     paused = true;
 
                 waited = false;
                 Invoke("waiting",0.3f);
             }
     }
 
     private void OnGUI()
     {
         if (paused)
             windowRect = GUI.Window(0, windowRect, windowFunc, "Pause $$anonymous$$enu");
     }
 
     private void windowFunc(int id)
     {
         if (GUILayout.Button("Resume"))
         {
             paused = false;
         }
         if (GUILayout.Button("Options"))
         {
 
         }
         if (GUILayout.Button("Quit"))
         {
 
         }
     }
 }
 
avatar image perchik · Aug 29, 2013 at 07:25 PM 0
Share

@Spy4812 please don't post a new question as a comment or answer.

8 Replies

· Add your reply
  • Sort: 
avatar image
11

Answer by Yoerick · Nov 11, 2010 at 11:27 AM

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)

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image eklumt · Jan 16, 2014 at 05:01 AM 0
Share

Cool and super simple, wish I had the rep to upvote this!

avatar image jonathanlemaster · Dec 06, 2016 at 03:05 PM 0
Share

this does not work it says the this is obsolete

avatar image karthik_47 · Sep 18, 2017 at 10:29 AM 0
Share

this is not working in unity 2017

avatar image
5

Answer by sillyjake · Jun 28, 2015 at 08:50 PM

For those using unity 5 or above, Its "Cursor.visble = false;" (C#) to hide the cursor.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
5

Answer by waqar1world · Aug 27, 2015 at 02:28 PM

//for Unity3d 5 using UnityEngine; using System.Collections;

public class CurserRemove : MonoBehaviour {

 // Use this for initialization
 void Start () {
     Cursor.visible = false;

 }
 
 // Update is called once per frame
 void Update () {
 
 }

}

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AddeWP · May 09, 2017 at 09:02 AM 0
Share

It does not work for me the cursor is still there

avatar image
3

Answer by Al-Anselmo · Dec 27, 2010 at 02:01 AM

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

Screen.lockCursor = true;

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image karthik_47 · Sep 18, 2017 at 10:30 AM 0
Share

but this is not working in Unity 2017.1.0f3

avatar image
0

Answer by BearMan11 · Dec 23, 2012 at 10:33 AM

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

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yu-gi-master · Mar 12, 2013 at 12:11 PM 0
Share

If you are new watch and read a few guides, like http://forum.unity3d.com/threads/34015-Newbie-guide-to-Unity-Javascript-%28long%29

avatar image DynamicPrgm · Mar 12, 2013 at 01:27 PM 0
Share

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

     var showing$$anonymous$$ouse : boolean;//for checking if mouse is shown or not
     
     function Start(){
     showing$$anonymous$$ouse = 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.Get$$anonymous$$eyDown($$anonymous$$eyCode.R) && showing$$anonymous$$ouse == false){
     showing$$anonymous$$ouse = true;
     Screen.showCursor =true;
     Screen.lockCursor = false;
     }
     //if you press "r" and the mouse is shown then make it not shown
     else if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.R) && showing$$anonymous$$ouse == true){
     showing$$anonymous$$ouse = false;
     Screen.showCursor =false;
     Screen.lockCursor = true;
     }
     
     }
avatar image robbiepaull1998 · Jul 19, 2013 at 07:12 AM 0
Share

thanks thats exactly what i wanted to do, to show and hide the mouse by one button

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

first person - hide mouse 1 Answer

Can I lock a cursor without hiding it? 0 Answers

Default Cursor hourglass during app load 2 Answers

Top Down Shooter: Panning Towards Cursor and / or rotating camera 0 Answers

Mouse move object according to grid 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges