Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Loading scene from asset bundle fails in Unity 5 only on iOS.

Discussion in 'Editor & General Support' started by Mandoz, Sep 16, 2015.

  1. Mandoz

    Mandoz

    Joined:
    Aug 30, 2013
    Posts:
    9
    Hi, guys,

    I tried to load scene from asset bundle but it always return 'Level 'TGStart' (-1) couldn't be loaded because it has not been added to the build settings.' message.

    I use same logic for Android and Standalone Windows and they works well.

    If anyone know how to solve this problem please let me know.

    I used script like below.

    Code (CSharp):
    1. WWW www = TGLoader.CreateWWW(strBuilder.ToString(), false);
    2.            
    3. yield return www;
    4.  
    5. if (ReferenceEquals(www.error, null) == false)
    6. {
    7.     if (ErrorLabel)
    8.     {
    9.         if (ErrorLabel)
    10.             ErrorLabel.text = www.error + " " + www.url;
    11.         Debug.Log("LoadAssetBundle : Try to load " + filename + " www.error = " + www.error);
    12.     }
    13.     LastLoadedObject = null;
    14.     yield break;
    15. }
    16.  
    17. if (ReferenceEquals(www.bytes, null))
    18. {
    19.     if (ErrorLabel)
    20.         ErrorLabel.text = "www.assetBundle" + " " + www.url;
    21.  
    22.     Debug.Log("LoadAssetBundle : Try to load " + filename + " www.bytes is null");
    23.     LastLoadedObject = null;
    24.     yield break;
    25. }
    26.  
    27. bundle = AssetBundle.CreateFromMemoryImmediate(www.bytes);
    28.            
    29. www.Dispose();
    30. www = null;
    31.  
    32. bundle.LoadAllAssets();
    33.  
    34. // to update loading scene
    35. yield return new WaitForEndOfFrame();
    36.  
    37. Application.LoadLevel(StartSceneName);
     
  2. Mandoz

    Mandoz

    Joined:
    Aug 30, 2013
    Posts:
    9
    FYI : it was fixed in 5.2.1f
    thanks!