Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by Cyanide · Mar 24, 2013 at 08:43 AM · menucursorlevelpause

Hiding the cursor on a certain level. Pause Menu help.

I have three levels to my game, the title screen, the controls menu, and the actual game menu, and I'm trying to work off this scrip for a pause menu.

function Update () {

//hide the cursor (at the beginning of the game)

Screen.showCursor = false; }

My problem is that when I have this script attached, It takes the cursor away for all three levels, when I only want the cursor to be disabled for the game level. How do I make it so that the cursor is visible for the title, and the controls menu, but not the Game. Also, since this Is also being used for a Pause menu i'm trying to work on, I have another question.

How do I get two 3d textures to pop up when I press escape? also one last thing. I have a script that should make the cursor appear when the escape button is pressed, but I'm not sure what to attach it to.

var script = GetComponent("HideCursorScript");

script.enabled = false;

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer Wiki

Answer by riko4628 · Mar 24, 2013 at 09:38 AM

What the cursor-hiding script is attached to? Try my script and attach it to the terrain or empty gameobject

 function Start ()
 {
     Screen.showCursor = false; 
 }
 
 function Update () 
 {
  if (Input.GetKey (KeyCode.Tab)) //when you press tab it will unlock the mouse
  {
      Screen.lockCursor = false; //the cursor is unlocked from center
      Screen.showCursor = true;  //cursor is visible
  }   
  else
  {
       Screen.lockCursor = true; //the cursor is locked to center
       Screen.showCursor = false; //cursor is invisibe
  }
 
 }

If this helped you please dont forget to press the like :)

V2:Press esc to unlock mouse from center and make it visible + lock camera movement, then press esc again to unlock.

 private var isPaused = false; 
 
 function Update () {
     
     Lock();
 
     if(Input.GetKeyDown("escape") && !isPaused)
 
     {
         cursorlock = false;
         isPaused = true;
         GetComponent(MouseLook).enabled = false;
         GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = false;
 
     }
 
     else if(Input.GetKeyDown("escape") && isPaused)
 
     {    
         isPaused = false;
         GetComponent(MouseLook).enabled = true;
         GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = true;      
 
     }
 
 }
 
 function Lock () {
 
     if (isPaused)
  {
      Screen.lockCursor = false; 
      Screen.showCursor = true;  
  }   
      if(!isPaused)
  {
       Screen.lockCursor = true;
       Screen.showCursor = false;
  }
  
 }
Comment
Add comment · Show 5 · 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 Cyanide · Mar 24, 2013 at 11:01 AM 0
Share

Thanks for your response, Pressing Tab does work, but you have to hold it, this is for a pause menu, so I need the cursor to stay enabled until the player presses tab again, any ideas on how to...

  1. pause the game the game showing the 3d textures (resume, and exit)

  2. keep the cursor visible while the pause screen is up without having to hold tab.

Thanks again, mate.

avatar image riko4628 · Mar 24, 2013 at 11:22 AM 0
Share

wait a sec im working on it :)

avatar image Cyanide · Mar 24, 2013 at 06:07 PM 0
Share

Amazing! I can't thank you enough! I have one more thing that I need help with. When you press esc, how can I get two 3d textures to show up? I want a Resume and exit button. I know how to make the buttons take you to separate levels, but I don't know how to make them appear only when you press esc. like the cursor. Thanks again.

avatar image riko4628 · Mar 24, 2013 at 07:57 PM 0
Share

do you mean something like when you press esc the box will pop up?

avatar image Cyanide · Mar 24, 2013 at 08:28 PM 0
Share

Well, I mean, when you press esc, the pause menu opens showing resume, and end. how do I get the game to pause and show the buttons?

avatar image
0

Answer by corriedotdev · Mar 24, 2013 at 02:17 PM

i agree with riko4628 , this is probs the best way to get around this.

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

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

12 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

Related Questions

add lockcursor to pause menu script?? 2 Answers

Pause menu doesn't pause everything 0 Answers

Script that makes the mouse cursor invisible. 3 Answers

Pause menu script, mouse not hiding 1 Answer

How to make a Main Menu 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