Search Unity

Asset bundle is not loading inside webplayer

Discussion in 'Scripting' started by Who-am-I, Jun 18, 2015.

  1. Who-am-I

    Who-am-I

    Joined:
    Mar 29, 2014
    Posts:
    73
    Hello guys,
    I have a small game with two scenes in unity 5.x, one is loader scene and second is main game scene. I wanna load main scene by asset bundle from my Localhost(http path). Its working fine with unity editor and Standalone Windows but When I build webplayer then asset bundle is not working..... :(:(:(

    WebPlayer Log file is

    150618 09:59:44 ------------------------------------------------------------
    150618 09:59:44 Manager starting, version 5.0.3f2_c28c7860811c
    150618 09:59:45 Requesting bundle 1 (5.x.x) update. Required revision range is 5108003 to 7fffffff, installed revision is ffffffff

    Second Log file is

    starting www download: http://Localhost:8080/Bundles/PC/scenes/scene.unity3d
    Platform assembly: C:\Users\Administrator\AppData\LocalLow\Unity\WebPlayer\player\Release-5.15.x.x\Data\lib\CrossDomainPolicyParser.dll (this message is harmless)
    Level 'main scene' (-1) couldn't be loaded because it has not been added to the build settings.
    To add a level to the build settings use the menu File->Build Settings...

    What am I doing wrong here... Please Help me ............:(:(:(:(
     
    Last edited: Jun 18, 2015
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    The obvious one: Have you added it to the build settings via file->build settings?

    Less obvious: Are you trying to load the same bundle twice? Perhaps by accident with a DontDestroyOnLoad object that isn't properly handling itself?

    Third: You might be in for the headache that is crossdomain security sandbox issues.
     
    Who-am-I likes this.
  3. Who-am-I

    Who-am-I

    Joined:
    Mar 29, 2014
    Posts:
    73
    Thank you for your quick response, I am trying again. I am really not understanding that what can I modify.
     
  4. Who-am-I

    Who-am-I

    Joined:
    Mar 29, 2014
    Posts:
    73
    The obvious one: Have you added it to the build settings via file->build settings?
    I have added only loader scene in build settings.

    Third: You might be in for the headache that is crossdomain security sandbox issues.
    Its fine because my other web players is player properly(Like other web players without asset bundle)

    Less obvious: Are you trying to load the same bundle twice? Perhaps by accident with a DontDestroyOnLoad object that isn't properly handling itself?
    How can I check this?

    Code (CSharp):
    1.         using (WWW www = WWW.LoadFromCacheOrDownload(path + bundleName, 3))
    2.         {
    3.             while (!www.isDone)
    4.             {
    5.                 label.text = (Mathf.Round(www.progress * 100f)).ToString() + "%";
    6.                 yield return new WaitForEndOfFrame();
    7.             }
    8.             yield return www;
    9.             if (!string.IsNullOrEmpty(www.error))
    10.             {
    11.                 label.text = www.error;
    12.                 yield break;
    13.             }
    14.             yield return new WaitForEndOfFrame();
    15.             try
    16.             {
    17.                 Application.LoadLevel(sceneName);
    18.             }
    19.             catch (Exception e)
    20.             {
    21.                 label.text = e.Message;
    22.             }
    23.             yield return new WaitForSeconds(2f);
    24.             www.assetBundle.Unload(false);
    25.             yield return null;
    26.             www.Dispose();
    27.         }
    This is my code for load a scene from asset bundle.
     
  5. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    is this issue resolved?
     
  6. Who-am-I

    Who-am-I

    Joined:
    Mar 29, 2014
    Posts:
    73
  7. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    share the solution
     
  8. Who-am-I

    Who-am-I

    Joined:
    Mar 29, 2014
    Posts:
    73
    Define the extension of asset bundle (.unity3d) and manifest (.manifest)