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 kranjo · Mar 24, 2013 at 01:53 AM · menupausepause game

How to show my cursor in Pause menu?

Hi. I have a pause menu script, but before that, I disabled my cursor from showing, cause otherwise it looks bad. How can I enable my cursor when i press "Escape" to go to the main menu? The script is this:

 var skin : GUISkin;
 var buttonOutlineAndTextColor = Color.white;
 var creditIcons : Texture[];
 var credits : String[] = ["Team Free Range."];
 var loadMainMenu : String;
  
 private var savedTimeScale : float;
 private var pauseFilter;
 private var currentPage : Page;
 private var toolbarInt : int = 0;
 private var toolbarStrings : String[] = ["Audio", "Graphics"];
 private var firstPersonControllerCamera;
 private var mainCamera;
 enum Page 
 {
     None, Main, Options, Credits
 }
 function LateUpdate() 
 {
     if (Input.GetKeyDown("escape")) 
     
     {
         switch (currentPage) 
         {
             case Page.None : PauseGame(); 
             break;
             
             case Page.Main : UnPauseGame(); 
             break;
             
             default : currentPage = Page.Main;
         }
     }
 }
  
 function OnGUI() 
 {
     if (skin != null) 
     {
         GUI.skin = skin;
     }
         
     if (IsGamePaused()) 
     {
         GUI.color = buttonOutlineAndTextColor;
         
         switch (currentPage) 
         {
             case Page.Main: PauseMenu(); 
             break;
             
             case Page.Options: ShowToolbar(); 
             break;
             
             case Page.Credits: ShowCredits(); 
             break;
         }
     } 
 }
  
 function ShowToolbar() 
 {
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     
     BeginPage(400, 200);
     
     toolbarInt = GUILayout.Toolbar (toolbarInt, toolbarStrings);
     
     switch (toolbarInt) 
     {
         case 0 : VolumeControl(); 
         break;
         
         case 1 : Qualities(); 
         QualityControl(); 
         break;
     }
     
     if (GUILayout.Button("Back")) 
     {
         currentPage = Page.Main;
     }
     
     EndPage();
 }
  
 function ShowCredits() 
 {
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     
     BeginPage(400, 200);
     
     for (var credit in credits) 
     {
         GUILayout.Label(credit);
     }
     
     for (var credit in creditIcons) 
     {
         GUILayout.Label(credit);
     }
     
     if (GUILayout.Button("Back")) 
     {
         currentPage = Page.Main;
     }
     
     EndPage();
 }
  
 function Qualities() 
 {
     switch (QualitySettings.currentLevel)
     {
         case QualityLevel.Fastest:
         GUILayout.Label("Fastest");
         break;
         
         case QualityLevel.Fast:
         GUILayout.Label("Fast");
         break;
         
         case QualityLevel.Simple:
         GUILayout.Label("Simple");
         break;
         
         case QualityLevel.Good:
         GUILayout.Label("Good");
         break;
         
         case QualityLevel.Beautiful:
         GUILayout.Label("Beautiful");
         break;
         
         case QualityLevel.Fantastic:
         GUILayout.Label("Fantastic");
         break;
     }
 }
  
 function QualityControl() 
 {
     GUILayout.BeginHorizontal();
     
     if (GUILayout.Button("Decrease")) 
     {
         QualitySettings.DecreaseLevel();
     }
     
     if (GUILayout.Button("Increase")) 
     {
         QualitySettings.IncreaseLevel();
     }
     
     GUILayout.EndHorizontal();
 }
  
 function VolumeControl()
 {
     GUILayout.Label("Use the slider to adjust the volume. Note that the volume is defaulted at 100%.");
     AudioListener.volume = GUILayout.HorizontalSlider(AudioListener.volume, 0.0, 1.0);
 }
  
 function BeginPage(width, height) 
 {
     GUILayout.BeginArea(Rect((Screen.width - width) / 2, (Screen.height - height) / 2, width, height));
 }
  
 function EndPage() 
 {
     GUILayout.EndArea();
 }
  
 function PauseMenu() 
 {
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "");
     
     BeginPage(400, 200);
     
     if (GUILayout.Button ("Continue"))
     {
         UnPauseGame();
     }
     
     if (GUILayout.Button ("Settings"))
     {
         currentPage = Page.Options;
     }
     
     if (GUILayout.Button ("Credits")) 
     {
         currentPage = Page.Credits;
     }
     
     if (GUILayout.Button ("Quit to Main Menu"))
     {
         Application.LoadLevel(loadMainMenu);
         Screen.showCursor = true;
     }
     
     EndPage();
 }
  
 function PauseGame() 
 {
     savedTimeScale = Time.timeScale;
     Time.timeScale = 0;
     AudioListener.pause = true;
     firstPersonControllerCamera = gameObject.Find("First Person Controller").GetComponent("MouseLook");
     mainCamera = gameObject.Find("Main Camera").GetComponent("MouseLook");
     firstPersonControllerCamera.enabled = false;
     mainCamera.enabled = false;
     
     if (pauseFilter) 
     {
         pauseFilter.enabled = true;
     }
     
     currentPage = Page.Main;
 }
  
 function UnPauseGame() 
 {
     Time.timeScale = savedTimeScale;
     AudioListener.pause = false;
     firstPersonControllerCamera.enabled = true;
     mainCamera.enabled = true;
     
     if (pauseFilter) 
     {
         pauseFilter.enabled = false;
     }
     
     currentPage = Page.None;
 }
  
 function IsGamePaused() 
 {
     return Time.timeScale == 0;
 }
  
 function OnApplicationPause (pause : boolean) 
 {
     if (IsGamePaused()) 
     {
         AudioListener.pause = true;
     }
 }



I saw it somewhere, but can't remember.. And it is great. Everything works, but I want it to show the cursor again, when I go to the Pause menu. Thanks

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · Mar 24, 2013 at 01:59 AM

You use Screen.showCursor = true in this script, so I'm confused. Can't you just do:

 case Page.Main :
    Screen.showCursor = true;
    UnPauseGame(); 
    break;
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
0

Answer by Leandro247 · Mar 24, 2013 at 03:37 AM

Use Screen.showCursor = true; and Screen.showCursor = false; (which was probably what you used for hiding).

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
0

Answer by kranjo · Mar 24, 2013 at 08:20 AM

I tried the show cursor script ofcourse, but I didn't try putting it in the case Page.Main part (i put it after the player pressed esc, because it made sense). I'll try this again. Tnx

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 kranjo · Mar 24, 2013 at 03:35 PM 0
Share

now it works.. i added the Screen.showCursor = true; to every "case" tnx

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

10 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

Related Questions

Pause Menu open/close on key 1 Answer

Pausing the game after player object gets destroyed 1 Answer

how to pause the mouselook script during pause? 1 Answer

Pause menu... Isn't pausing everything... 1 Answer

How to save players position then load a level (pause menu) 2 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