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 Ben Humphreys · Jul 04, 2013 at 02:31 AM · crashloadlevelloadlevelasync

LoadLevelAsync Causes Unity to Crash?

I'm trying ot use LoadLevelAsync for the first time, in Unity Pro 4.1.5f1. The following script in an empty scene, attached to an empty GameObject, causes the Unity editor itself to hang, every time.

Does this happen for other people? What am I doing wrong? This looks OK to me...

 using UnityEngine;
 using System.Collections;

 public class SceneLoader : MonoBehaviour {
     string targetScene = "MainGame";
 
     AsyncOperation asyncOp;
 
     IEnumerator Start() {
         // Load and wait
         asyncOp = Application.LoadLevelAsync(targetScene);
         asyncOp.allowSceneActivation = false;
 
         yield return asyncOp;
         Debug.Log("Load complete!");
     }
     
     void Update () {
         if (asyncOp.isDone) {
             Debug.LogError("Done Loading");
         }
     }
 
     void OnGui() {
         if (asyncOp != null) {
             GUI.Box(new Rect(0, Screen.height - 40, asyncOp.progress * Screen.width, 40), "");
         }
     }
 }

It seems without the asyncOp.allowSceneActivation = false; line, it works. I wanted to start a fade transition on load complete, so I don't want it to swap scenes for me.

Comment
Add comment · Show 5
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 Benproductions1 · Jul 05, 2013 at 08:27 AM 0
Share

It probably crashed because you caused it to have some sort of infinite loop. Does "SceneLoader" possibly exist in the other scene as well?

avatar image Ben Humphreys · Jul 05, 2013 at 08:43 AM 0
Share

Thanks for the reply. It doesn't exist in other scenes. The error also only occurs when I try to use Async loading on a large scene. It works fine with smaller scenes and with large scenes non-asynchronously. Unity's async loader seems to just die.

avatar image Benproductions1 · Jul 05, 2013 at 09:00 AM 0
Share

Do you have a crash report? This may be a Unity bug

avatar image Ben Humphreys · Jul 05, 2013 at 09:01 AM 0
Share

I sent one to Unity when it crashed before. No reply yet.

avatar image Benproductions1 · Jul 05, 2013 at 09:12 AM 0
Share

They should be on the case. $$anonymous$$eanwhile can you also post the error report here?
Someone might come to a solution quicker than them :)

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by InfiniBuzz · Jul 05, 2013 at 09:57 AM

Remove the

 asyncOp.allowSceneActivation = false;

this does load the level but never activate your scene (actually finish loading). You cannot abort a loading operation since the objects in the current scene are being unloaded. Remove the line or set allowSceneActivation to true somewhere.

 asyncOp.allowSceneActivation = true;

To have a fading in the new scene you have to setup the overlay on the new (the loaded) scene and then start the fading from there. It is not possible to finish the scene loading without allowSceneActivation (this blocks the loading at about 90% if I remember right).

Hope you understand me and it helps ;)

edit: the fading like you do it now, does it not work without allowSceneActivation = false; ?

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

17 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

Related Questions

Loading Scene in between two scene for web player. 0 Answers

LoadSceneOnClicks.LoadAsynchronously(int)': not all code paths return a value 1 Answer

Application.LoadLevelAsync() causes Unity crash? 2 Answers

LoadLevelAsync and load data before allowSceneActivation 1 Answer

iPad crashes on load level 2 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