- Home /
Unity editor crashes after LoadSceneAdditive or LoadLevelAdditiveAsync
I always have a unity crash when I attempt to do LoadSceneAdditive or LoadLevelAdditiveAsync.
I have 5 scenes :
Root : Contains a camera and a emptyGameObject with my component "Loaded"
streamed1 : a sphere
streamed2 : a capseul
streamed3 : a sphere
streamed4 : a 3dText with a custom font
I build a scene asset bundle :
string[] levels = new string[] { "Assets/streamed1.unity", "Assets/streamed2.unity", "Assets/streamed3.unity", "Assets/streamed4.unity" };
BuildPipeline.BuildStreamedSceneAssetBundle( levels, "Assets/StreamingAssets/streamed.unity3d", BuildTarget.WebPlayerStreamed);
My component Loaded
using UnityEngine;
using System.Collections;
public class Loaded : MonoBehaviour {
// Use this for initialization
IEnumerator Start () {
#if UNITY_EDITOR
string filePath = "file:///" + Application.streamingAssetsPath+"/streamed.unity3d";
#elif UNITY_WEBPLAYER
string filePath = System.IO.Path.Combine( "StreamingAssets", "streamed.unity3d");
#else
string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "streamed.unity3d");
#endif
WWW www = new WWW(filePath);
yield return www;
AssetBundle asset = www.assetBundle ; // Pour que ça marche
Debug.Log("load OK") ;
for (int i = 1 ; i < 5 ; i++) {
float progress = Application.GetStreamProgressForLevel("streamed"+i) ;
while (!Application.CanStreamedLevelBeLoaded("streamed"+i)) {
progress = Application.GetStreamProgressForLevel("streamed"+i) ;
Debug.Log("wait ("+Mathf.Round(progress * 100)+"%)") ;
yield return new WaitForSeconds(0.1f) ;
}
Debug.Log("scene ready") ;
Application.LoadLevelAdditive("streamed"+i) ;
/*AsyncOperation async = Application.LoadLevelAdditiveAsync("streamed"+i) ;
while (!async.isDone) {
Debug.Log("prepare scene"+i) ;
yield return new WaitForSeconds(0.1f) ;
}*/
}
Debug.Log("finished") ;
}
}
The crash comes after the load scene streamed4.
What can I do now ?
Thanks
Comment
Best Answer
Answer by sdete · Jul 19, 2013 at 12:41 PM
I solved it by update my Unity editor version. This crash is now fixed.
Your answer