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
1
Question by Fesker · Jul 24, 2012 at 09:39 PM · sceneloadlevelapplicationmain menu

Application.LoadLevel() doesn't clear screen

Hi people! I'm really new on this and I need your help if you can. I'm watching a nice tutorial that teaches me to do a Main Menu. This menu needs to load up another level, but when I do, I keep seeing the buttons I clicked. Menu scene's name is sceneMainMenu.

Thx for helping and sorry for my english. Here is the code.

 function OnGUI () 
 {
  if (GUI.Button(Rect(10,10,100,50),"Start Game"))
  {
  //print("Starting Game...");
  Application.LoadLevel ("sceneLevel1");
  }
  if (GUI.Button(Rect(10,70,100,50),"Exit Game"))
  {
  //print("Quitting Game...");
  Application.Quit();
  }
 }
Comment
Add comment · Show 4
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 Bovine · Jul 24, 2012 at 09:49 PM 1
Share

Are any objects in your menu scene marked as DontDestroyOnLoad() ?

http://docs.unity3d.com/Documentation/ScriptReference/Object.DontDestroyOnLoad.html

Do you have any errors in the console?

Is your sceneLevel1 added to the build?

avatar image Fesker · Jul 25, 2012 at 12:05 AM 1
Share

Got It. $$anonymous$$y script$$anonymous$$ain$$anonymous$$enu was attached to my camera at sceneLevel1. Noob error. Sorry for opening an answer for that.

Thx for help.

avatar image Default117 · Jul 25, 2012 at 12:11 AM 0
Share

What does your sceneLevel1 contain? Perhaps you have the same onGUI script attached to an object in the scene you're loading?

avatar image zigarot · Mar 29, 2015 at 04:24 PM 0
Share

Also, I removed my mainCamera items from my menus. Apparently my event system or whatnot didn't like that, kept overlaying new scenes over the old ones. added it back in to each menu, tags and all, all good now :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by JChilton · Jul 25, 2012 at 01:59 AM

The script that is calling OnGUI still exists, and will continue to draw to the GUI.

If there's nothing else in that script that you require, destroy it after it's loaded. Alternatively, if you want to keep the second button (quit), have some boolean check for when to disable the first button.

1:

 function OnGUI () 
 {
  if (GUI.Button(Rect(10,10,100,50),"Start Game"))
  {
  //print("Starting Game...");
  Application.LoadLevel ("sceneLevel1");
  Destroy(this);
  }
  if (GUI.Button(Rect(10,70,100,50),"Exit Game"))
  {
  //print("Quitting Game...");
  Application.Quit();
  }
 }

or:

 //if .cs
 bool showStart = true;
 //if .js
 var showStart = true;
 
 function OnGUI () 
 {
  
  if(showStart)if (GUI.Button(Rect(10,10,100,50),"Start Game"))
  {
  //print("Starting Game...");
  Application.LoadLevel ("sceneLevel1");
  showStart = false;
  }
  if (GUI.Button(Rect(10,70,100,50),"Exit Game"))
  {
  //print("Quitting Game...");
  Application.Quit();
  }
 }
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 Default117 · Jul 25, 2012 at 02:01 AM 0
Share

Application.LoadLevel will destroy this object anyway, so it can't be that problem. He answered his own question, the same script was attached to another object in his second scene.

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

8 People are following this question.

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

Related Questions

Application.Loadlevel("Level Name"); not working on android 2 Answers

How to create a complicated game over scene ? Help 1 Answer

Can I utilize LoadLevelAdditive for immersive game? 2 Answers

Problem with Application.Loadedlevel 0 Answers

Load / Stream 3rd Party 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