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 Domo23000 · Feb 08, 2014 at 12:17 AM · scene-loadingloadlevel

LoadLevel Doesn't have script

i have a main menu scene, that goes to the game scene without problems, but when i go back to the menu, the menu script doesn't show. Any solutions?

Main Menu

 private var canShow : boolean = false;
 var Skin : GUISkin;
 
 private var Name : String;
 var playerName : String;
 
 private var lastScore : int;
 private var myscore : int;
 
 function Awake()
 {
     Name = PlayerPrefs.GetString("MyName");
     playerName = Name;
     
     myscore = PlayerPrefs.GetInt("MyScore"); 
     lastScore = myscore;
 }
 
 function Update()
 {
     Go();
 }
 
 function OnGUI()
 {
     //GUI.skin = Skin;
 
     if(canShow == true)
     {
         if(GUI.Button(Rect(Screen.width/2 - 200, Screen.height/2, 400, 100), "New Game"))
         {
             Application.LoadLevel(1);
         }
         
         if(GUI.Button(Rect(Screen.width/2 - 200, Screen.height/2 + 100, 400, 100), "Quit Game"))
         {
             Application.Quit();
         }
         
         GUI.Box(Rect(0, 0, 200, 150),"Welcome Back");
         playerName = GUI.TextField(Rect(50, 25, 100, 25), playerName, 10);
         
         PlayerPrefs.SetString("MyName", playerName);
         
         
         GUI.Box(Rect(50, 75, 100, 25), "Last Score");
         GUI.Box(Rect(50, 100, 100, 25), lastScore.ToString());
     }
 }
 
 function Go()
 {
     yield WaitForSeconds(2);
     canShow = true;
 }

Pause

private var paused : boolean = false;

function Awake() { Screen.lockCursor = true; }

function Update() { if(Input.GetButtonDown("Pause")) { if(Screen.lockCursor == false) { Screen.lockCursor = true; Time.timeScale = 1.0;

         MouseLook.sensitivityX = normalSensitivity;
         MouseLook.sensitivityY = normalSensitivity;
         
         paused = false; 
     }
     
     else
     
     {
         Screen.lockCursor = false;
         Time.timeScale = 0.0;
         
         MouseLook.sensitivityX = 0;
         MouseLook.sensitivityY = 0;
         
         paused = true;
     }        
 }

}

function OnGUI() { if(paused == true) { if(GUI.Button(Rect(Screen.width/2 - 200, Screen.height/2, 400, 100), "Main Menu")) { Application.LoadLevel(0); }

     if(GUI.Button(Rect(Screen.width/2 - 200, Screen.height/2 + 100, 400, 100), "Quit Game"))
     {
         Application.Quit();
     }

     GUI.Box(Rect(Screen.width/2 - 100, Screen.height/2 - 100, 200, 50), "Paused");    
 }

}

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 getyour411 · Feb 08, 2014 at 12:23 AM 1
Share

You start Go() from Update (with no filter) so it's called every frame. $$anonymous$$aybe that resets your 'yield WaitFor...' so it never reaches the canShow

avatar image Domo23000 · Feb 08, 2014 at 12:50 AM 0
Share

taking yield out worked but i found out another reason why it happened, thanks! :D

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by JSierraAKAMC · Feb 08, 2014 at 12:23 AM

 if(paused == true)
 { 
 if(GUI.Button(Rect(Screen.width/2 - 200, Screen.height/2, 400, 100), "Main Menu"))
 { 
 Application.LoadLevel(0); 
 }
 }

Needs to be

 if(paused == true)
 { 
 if(GUI.Button(Rect(Screen.width/2 - 200, Screen.height/2, 400, 100), "Main Menu"))
 { 
 Time.timeScale = 1.0;
 Application.LoadLevel(0); 
 }
 }

or else it will remain "paused." Note that the time scale would still be 0 at the main menu.

Comment
Add comment · Show 2 · 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 Domo23000 · Feb 08, 2014 at 12:52 AM 0
Share

oohh, thanks for the answer JSierraA$$anonymous$$A$$anonymous$$C :D it worked

avatar image JSierraAKAMC · Feb 08, 2014 at 01:28 AM 0
Share

You're welcome! If you have any questions, just ask! :D

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

18 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 avatar image

Related Questions

help please: Level Changing Scipt 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

[Solved]Application.LoadLevel("Scene"); not working! 2 Answers

SceneManager.LoadSceneAsync causes lag spikes, how to make background loading less CPU heavy 1 Answer

Rotation stops when reload scene 1 Answer


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