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 oliver-jones · Feb 20, 2014 at 01:27 PM · sceneloadapplicationasyncstops

LoadLevelAsync - Stops Randomly?

I'm using 'Application.LoadLevelAsync' to load my game level from my main menu.

But about 3 out of 5 tries, it will just ... stop, and freeze! (This only happens when built and running on my iOS devices - doesn't happen within the editor).

It doesn't crash, nor is Xcode throwing any errors, it just simply stops, mainly at around 80% level loaded. Although my loading music is still playing.

Can anyone explain this?

This is my function thats called when loading a new scene:

 function LaunchGame(players : String, game : String, table : String){
 
     print("[MC] Launching Game!");
 
     PlayerPrefs.SetInt("background_colour", backgroundRandom);
     PlayerPrefs.SetString("player_type", players);
     PlayerPrefs.SetString("game_type", game);
     PlayerPrefs.SetString("table_type", null);
 
     yield WaitForSeconds(1.5);    
 
     print("[MC] Loading...");
 
     var async = Application.LoadLevelAsync(1);
     while (!async.isDone) {
         print ("%: " + async.progress);
         yield;
     }
 }

Thanks.

Comment
Add comment · Show 3
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 jacksmash2012 · Feb 20, 2014 at 01:44 PM 0
Share

Stupid question, but are there any errors shown in the console that originate from the scene that is being loaded? They may not necessarily stop things from "working" in the editor. I've had this happen in the past so just thought I'd check.

avatar image oliver-jones · Feb 20, 2014 at 01:57 PM 0
Share

The only error I get right before the scene is loaded is a 'Broadcast $$anonymous$$essage has no receiver'. I'll patch that up and see if it stops. This warning comes up all the time, yet my scene only loads the majority of the time. So I doubt it is that, but - better to be safe than sorry.

avatar image jacksmash2012 · Feb 20, 2014 at 02:21 PM 0
Share

You must be sending a message somewhere in a script, that has a null receiver. $$anonymous$$aybe. But yeah, I'd definitely clean that up first. $$anonymous$$ake sure there are no errors in the editor whatsoever, and then see if it still crashes on the device.

1 Reply

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

Answer by oliver-jones · Feb 20, 2014 at 04:21 PM

I couldn't find the problem exactly, but I personally think it gets stuck when trying to load the scene within the background and then once loaded, jump right into the new scene.

So what I did was made the scene load about 2 seconds after the Main Menu has loaded, but DON'T launch into it. I only launch into it when the user clicks play.

This benefits me in two ways:

1) My game never crashes during loading

2) When the player clicks play, the scene is much quicker to load in, as the majority of it has already loaded.

I do this by calling this function when I want to load the scene, but not launch it (so call it within Start)

 var async : AsyncOperation;
 function LoadGameInBackground(){
 
     async = Application.LoadLevelAsync(1);
     async.allowSceneActivation = false;
 
     while(async.progress < 0.9){
 
         print(async.progress + "%");
         yield;
 
     }
 
     print("Level loaded in background - waiting for launch prompt");
 }

Then when the user clicks play, this function is then called, which activates the scene:

 function LaunchGame(players : String, game : String, table : String){
 
     print("[MC - Launch] Saving game types");
     PlayerPrefs.SetInt("background_colour", backgroundRandom);
     PlayerPrefs.SetString("player_type", players); //solo, host, join, passngo
     PlayerPrefs.SetString("game_type", game);
     PlayerPrefs.SetString("table_type", null);
 
 
     yield WaitForSeconds(0.5);
     print("[MC - Launch Active] Activating new scene");
     async.allowSceneActivation = true;
 
 }
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

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

19 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

Related Questions

Unloading a loaded Scene when load Async for a Loading Bar 1 Answer

Loading player location in a scene 2 Answers

Click Object to change scene 2 Answers

Restarting a Scene 1 Answer

Game image shifts Down to the Left with 1280x720 monitors. (Running standalone player on Linux with Xinit ) 0 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