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 gogo199432 · Feb 22, 2014 at 11:02 AM · crashesgame editorlevelloadbuilt

Aplication.LoadLevel isn't working in built version

Hi guys!

I encountered this problem only yesterday, before that everything worked fine, and I didn't change anything. But this is not new with Unity, now is it? :D Anyway, so I have my main menu screen with the play button as a empty, with collider, and a Text mesh. What is happening when I click on the play button in the built version, is that the whole game crashes. However in the editor, everything works just fine... I hope you can help me, because I see nothing wrong. Also just an info, I have the scenes in the build editor and they are all checked. I tried the script with an int too instead of a string, same result. On to the script:

 var levelToLoad : String;
 var soundhover : AudioClip;
 var beep : AudioClip;
 var QuitButton : boolean = false;
 
 function OnMouseEnter()
 {
     audio.PlayOneShot(soundhover);
 }
 
 function OnMouseUp()
 {
     audio.PlayOneShot(beep);
     //yield WaitForSeconds(0.35);
     if(QuitButton)
     {
         Application.Quit();
     }else
     {
         Application.LoadLevel(levelToLoad);
     }
 }
 @script RequireComponent(AudioSource)
Comment
Add comment · Show 6
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 gogo199432 · Feb 22, 2014 at 04:29 PM -1
Share

$$anonymous$$aybe I wasn't clear enough. I know that my scene has a number, and they are added in the Scenes to build window. (I want to load the 2nd scene btw). And I set the string in the inspector, so the script is reusable. I tried it with string and number too, both loads in the editor just fine, but not in the built version.

avatar image sdgd gogo199432 · Feb 22, 2014 at 05:11 PM 0
Share

first of all don't post comments as answers.

second of all did you read my answer?

and because you have made an answer I have down voted your answer

avatar image gogo199432 · Feb 22, 2014 at 09:46 PM 0
Share

Sorry, for being rude, didn't read through your answer carefully enough :) But it still isn't working :(

avatar image sdgd · Feb 23, 2014 at 01:08 AM 0
Share

hmmm, ... I'm out of ideas, as it worked for me, ...

can you update your code how are you trying to solve it?

and after changing the code did you build it again?

avatar image gogo199432 · Feb 23, 2014 at 09:28 AM 0
Share

Here is the code I'm using now: var levelToLoad : String = "HospitalScene01"; var soundhover : AudioClip; var beep : AudioClip; var QuitButton : boolean = false;

 function On$$anonymous$$ouseEnter()
 {
     audio.PlayOneShot(soundhover);
 }
 
 function On$$anonymous$$ouseUp()
 {
     audio.PlayOneShot(beep);
     //yield WaitForSeconds(0.35);
     if(QuitButton)
     {
         Application.Quit();
     }else
     {
         Application.LoadLevel(levelToLoad);
     }
 }
 @script RequireComponent(AudioSource)

I did rebuild it, but it still wasn't working :/ Also here is the crashreport I get, in case it helps anything: http://pastebin.com/6qSTkn6Y

avatar image gogo199432 · Feb 23, 2014 at 09:35 AM 0
Share

Okay, I have no f*cking idea why, but it is working now. I just deleted the scene from the build window and readded it...unity...

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Zentiu · Feb 22, 2014 at 12:14 PM

1) Check if the scene you want to load is in your BuildSettings under "Scenes in Build".

2) use the code Application.LoadLevel ("nameOfTheSceneIWantToLoad");

or

Application.LoadLevel (1);

the scenes you put in the buildsettings start from 0 counting up so your main menu might be 0 and your first level might be 1, next level 2, third level 3 ect.

3) don't know about javascript but in c# I don't need to make a variable for it.

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 sdgd · Feb 22, 2014 at 12:28 PM 0
Share
 Application.LoadLevel (1); // you just made variable here. int 1

if you want to use no variable you do:

 int variableLevel;
 Application.LoadLevel (variableLevel);

but afaik in C# you get error as you didn't set the variable before use.

avatar image Zentiu · Feb 22, 2014 at 01:04 PM 0
Share

I have it in c# and I haven't put a variable in and it works just fine. all ya need to do in c# is write the name of the screen you wish to load as a string in the LoadLevel brackets and you're good to go.

 Application.LoadLevel (1);
 
 //or as a string
 
 Application.LoadLevel("myNewScene");

ohw wait, you're right if you don't have either a variable or the stringname in those brackets.

don't $$anonymous$$d me.. just a little tired :/

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

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

Related Questions

Unity wont launch PDF when built, works in editor 1 Answer

App Crashing on iPhone due to Texture Memory 2 Answers

Unity crashes on selection of prefab in project tab 0 Answers

Random crash in ntdll.dll 0 Answers

unity 5.6.5f1 crash skin matrices must be 16 byte 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