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?
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)
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.
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)
Grimmy, I’d be very interested in knowing if you found some way to make this work on iOS. Though my guess is that you encountered the same problems as Asse originally posted, as that’s what I’m getting.
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.
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!
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?
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.
List<string> Levels = new List<string>();
EditorBuildSettingsScene[] Scenes = EditorBuildSettings.scenes;
foreach(EditorBuildSettingsScene Scene in Scenes)
{
if (!Scene.enabled)
{
Levels.Add(Scene.path);
}
}
if (Levels.Count > 0)
{
BuildPipeline.BuildStreamedSceneAssetBundle( Levels.ToArray() , "StreamingLevels",
EditorUserBuildSettings.activeBuildTarget);
}
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.
AssetBundle Levels;
WWW Loader = WWW.LoadFromCacheOrDownload("http://myhost/StreamingLevels", 2);
while (!Loader.isDone)
{
Debug.Log(Loader.progress);
yield return new WaitForSeconds(0.5f);
}
if (Loader.error == null)
{
Levels = Loader.assetBundle;
}
else
Debug.LogError(Loader.error);
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.
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.