Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
1
Question by esitoinatteso · Nov 11, 2015 at 12:00 AM · buildbuild-errorglitchstandaloneapplication.loadlevel

Standalone build fails Application.LoadLevel() and Freezes

Hi there again!

I've tracked down another bug of a line that worked fine in editor and, for some reason, it does it wrong in the build.

Here's the chunk of code from the scene named VeryFirstSceneEver, I'll provide an overview about what's happening nearby it so you can have an idea:

     /// <summary>
     /// Moves to Quit OR ProtoMenu!
     /// </summary>
     void MoveOn(){
 
         //Once rendering is over...
         if(textBehaviour.Rendered){
 
             //If user refuses...
             if(responsibilityRefused){
                 
                 Application.Quit();
             }
             else{
 
                 //Go cat go!
                 if(Input.anyKeyDown){
 
                     Application.LoadLevel("ProtoMenu");
 
 //                    StartCoroutine("LoadNext");
                 }
             }
         }
     }
 
 //    IEnumerator LoadNext(){
 //
 //        Debug.Log("Trying to load ProtoMenu, hope this works");
 //
 //        yield return new WaitForSeconds(1f);
 //
 //        line above is the last thing that gets processed, we never reach the one below.
 //        Application.LoadLevel("ProtoMenu");
 //        Debug.Log("The call is passed, let's see the effects!");
 //    }

I've tested with Debugs both from editor and from build, the results are:

Editor loads the scene called ProtoMenu every time, both with the Coroutine method ( that I dislike) and the straight one.

Build fails at loading ProtoMenu, and stops giving me feedback as soon as Input.AnyKeyDown is true ( I placed inside it a Debug and I never heard of it), or as soon as yield returns with the coroutine method... Or I should say as soon as 1 second from the start of the coroutine is through.

Now a bonus thing: Even if I can't leave this scene without freezing, before I call Application.LoadLevel() I create a couple of Directories against which the Preloading Scene of Unity does this check:

         if(Directory.Exists(Application.persistentDataPath + "/Scenes Directory")){
 
             Application.LoadLevel("ProtoMenu");
         }
         else{
 
             Application.LoadLevel("VeryFirstSceneEver");
         }

Since those Directories are there, the next time I launch the Build, the first condition is used.

And the first condition loads ProtoMenu scene without a line of warning.

But then a similar pattern occurs: I have to load a 3rd scene from the 2nd scene loaded since game's launch.

Guess what? the game freezes for each once again.

That's what makes me believe that something is jamming with Application.LoadLevel();

Thanks a bunch for any suggestions!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by esitoinatteso · Nov 11, 2015 at 02:43 PM

Hi there! Got beefy news: I solved the problem with a workaround.

I'd like to know what was wrong in the first place though, if one is experienced enough about what's going on under the hood and has some spare time to enlighten me I'd be grateful!

So...

IF your build freezes and doesn't load scenes via Application.LoadLevel(); you make a new scene with an empty game object.

You attach to that object a script like this:

 using UnityEngine;
 using System.Collections;
 
 public class LoaderOfScenes : MonoBehaviour {
 
     // Use this for initialization
     void Awake () {
     
         //Just load a specific scene...
         Application.LoadLevel(References.SceneToLoad == null ? "<Put your Default Scene name here" : References.SceneToLoad);
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 }

Then you need another class to store the string variable used to pick the proper scene.

I use References, which is just a plain public static class stored inside the folder of my scripts. The code for the string is this:

     static string sceneToLoad;
     public static string SceneToLoad{
         get{
             return sceneToLoad;
         }
         set{
             sceneToLoad = value;
         }
     }

So, nothing to fancy.

When I run a build that, instead of using Application.LoadLevel(< the scene I need>); asap, loads the one where I saved the empty game object to which LoaderOfScenes is attached... somehow everything works.

I'm clueless about why this exactly happens.

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 WILEz1975 · Mar 14, 2016 at 01:37 AM 0
Share

This solution not work for me... XD In editor is all ok, but in build the application crash when load a new 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

37 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 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

weird errors and warnings after build 0 Answers

Windows standalone build error 0 Answers

Unity 2019.3.9f1 WebGL build error TypeLoadException when making release build 3 Answers

Texture importer API doesn't work on build exe 0 Answers

My windows standalone build doesn't work at all. 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