Search Unity

No BuildOptions.BuildAdditionalStreamedScenes

Discussion in 'iOS and tvOS' started by Asse83, Feb 19, 2010.

  1. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    For our PC version we build additional scene with BuildOptions.BuildAdditionalStreamedScenes so we can load them without adding them to the built-settings (to deliver scenes after shipping).

    Unfortunately this option isn't available for Unity iPhone. Is there a way around this?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    On the iPhone you would need iPhone Advanced and do what you commonly do optimally too on the pc: use Asset Bundles (instead on relying on the webplayer loadin feature thats not really comparable to scene loading as you lose all data from previous scenes)
     
  3. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    But works also perfect on the standalone version. AssetBundles can't contain scenes so that's probably not an option.

    The Unity3D iPhone doc tells about streaming additional scenes through WWW so there must be a way to build separate scenes.
     
  4. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    EDIT: The error message received when trying to create a scene as AssetBundle:

    Asset bundles can not include Scenes: folder/anotherfolder/myscene.unity
    If you want to stream a Scene, use BuildPipeline.BuildPlayer with BuildOptions.BuildAdditionalStreamedScenes.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    You can't build scenes to asset bundles as scenes are neither assets nor even unity objects

    What you would do is take the whole content of the scene, put it into an asset bundle and then instead of loading that scene through LoadLevel, you would load into an empty scene and instantiate the whole content of the asset bundle basically.


    Asset Bundles can only store assets (sound, texture, text, model), but no things that are no assets (code, scenes)
     
  6. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    Yeah, that's a great idea. I'll try this. Thanks!
     
  7. grimmy

    grimmy

    Joined:
    Feb 2, 2009
    Posts:
    409
    But surely you can bundle scenes! Here's an extract from the Unity docs..


    BuildOptions.BuildAdditionalStreamedScenes
    Description
    Build a unity3d / asset bundle that contains additional streamed scenes.

    This allows you to on demand load scenes and their assets when needed instead of a simple linear progressing download.

    I am in the middle of doing this now. I have already bundled the scenes but now I'm trying to figure out how to stream them in..
     
  8. Steven-Walker

    Steven-Walker

    Joined:
    Oct 27, 2010
    Posts:
    38
  9. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Currently you can't build streamed scenes for the purpose of downloading them using the WWW class for iOS.

    For Unity 3.4 we will have support for building streamed scenes including a simpler API for building them on all Platforms.
    We also made the caching API enabled on all platforms. So with 3.4 you get the full package of what you need to make very easy to build game patching and additional level packs.
     
  10. RazorCut

    RazorCut

    Joined:
    May 7, 2009
    Posts:
    393
    woot! Ticked me off that I found out the long and hard way (i.e. the docs don't tell you!) that the cache feature wasn't available on iOS. Glad to hear it's SOON!
     
  11. padworx

    padworx

    Joined:
    Mar 22, 2011
    Posts:
    27
    Any ETA on this feature (or ETA for unity 3.4?) We require this to bypass the 50mb download limit on Android devices, however now it seems this is impossible in Unity 3.3?
     
    Last edited: May 9, 2011
  12. AdsySingle

    AdsySingle

    Joined:
    Jan 5, 2011
    Posts:
    116
    So as I understand it this feature (or features) is up and running with 3.4 Can anyone point me in the direction of some clear instructions or a walk through on this. We are looking at doing a major update for our already existing game and this will push it over the 20MB mark. We would like to avoid that if possible by having the new scenes and content downloaded from within the game, but I have no idea how to go about it or what limitations there are on the new content and scene.
     
  13. Fooo

    Fooo

    Joined:
    Mar 11, 2011
    Posts:
    41
    Building side:
    Code (csharp):
    1.  
    2.         List<string> Levels = new List<string>();
    3.         EditorBuildSettingsScene[] Scenes = EditorBuildSettings.scenes;
    4.  
    5.         foreach(EditorBuildSettingsScene Scene in Scenes)
    6.  
    7.         {
    8.  
    9.             if (!Scene.enabled)
    10.  
    11.             {
    12.                 Levels.Add(Scene.path);
    13.             }
    14.  
    15.         }
    16.         if (Levels.Count > 0)
    17.  
    18.         {
    19.  
    20.             BuildPipeline.BuildStreamedSceneAssetBundle( Levels.ToArray() , "StreamingLevels",
    21.  
    22.                            EditorUserBuildSettings.activeBuildTarget);
    23.  
    24.         }
    25.  
    This creates a file called StreamingLevels that you upload to a CDN/web server somewhere.

    Game side:
    Somewhere before you need to load the scenes.
    Code (csharp):
    1.  
    2.                         AssetBundle Levels;
    3.             WWW Loader = WWW.LoadFromCacheOrDownload("http://myhost/StreamingLevels", 2);
    4.  
    5.             while (!Loader.isDone)
    6.  
    7.             {
    8.  
    9.                 Debug.Log(Loader.progress);
    10.  
    11.                 yield return new WaitForSeconds(0.5f);
    12.  
    13.             }
    14.  
    15.             if (Loader.error == null)
    16.  
    17.             {
    18.  
    19.                 Levels = Loader.assetBundle;
    20.  
    21.             }
    22.  
    23.             else
    24.  
    25.                 Debug.LogError(Loader.error);
    26.  
    27.  
    After it's loaded successfully, you can now load levels. I keep a static reference to the asset bundle around so it never unloads - not sure if it would if it went out of scope.

    I've found that things like Application.loadedLevel and Application.loadedLevelName no longer work with streaming levels in this case BTW.
     
  14. Tsu

    Tsu

    Joined:
    Dec 4, 2008
    Posts:
    1
    What is the size limit for mobile device?
     
  15. jtbentley

    jtbentley

    Joined:
    Jun 30, 2009
    Posts:
    1,397
    So I've got a 150mb game I want entirely wrapped into one neat package that will then work as per normal. Application.loadedLevelName is functionality I use often.

    Thoughts?