I'm busy wrapping up a project and i have 11 scenes in my game. My interface is done in Flash and i'm loading my game swf in. The way i'm managing the scenes is with a Loading Scene in the unity swf which is empty but has a controller to load the right scene. So now i've added all 11 scenes to the project and trying to export it to a swf but the resulting swf ends up being 4 bytes big and no error thrown! Having removed scenes 1 at a time I find that i can't add the last two scenes. File size was already past the 500mb at this point. How can i solve this?
Try having each of your scenes exported to an asset bundle and loaded at runtime so that your main swf is smaller.
Hmm, how do you recon i go about creating and loading them? I don't have mu experience with asset bundles. Let alone converting that to flash [Edit] Just found streamedScene assetbundles. Sounds like that will do the trick! [Edit 2] Hmm.. Can i use www to load local files in flash??
Yes, you should be able to load the local files. You'll need to make sure that the location of the files is added to your flash player security settings: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html Keep an eye on your flash log when you try to load the asset bundles, as this will tell you if there are any errors or security issues.
Aye, i got all that setup but since i'm exporting to flash Application.path and such aren't available and WWW needs file:// to get the local file. Do you know if there is a way to get a relative path in there?
Try getting the path relative to your main swf, e.g.: Code (csharp): if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor) download = new WWW ("file://" + Application.dataPath + "/../AssetBundles/Shared.swf"); else if(Application.platform == RuntimePlatform.FlashPlayer) download = new WWW ("./AssetBundles/Shared.swf");
Hmm following what's in the docs and what you posted above the code looks like this: Code (csharp): IEnumerator Start() { /*Object[] loaders = FindObjectsOfType(typeof(Loader)); if(loaders.Length > 1) DestroyImmediate( gameObject );*/ string path = ""; #if UNITY_EDITOR path = "file://" + Application.dataPath + "/../AssetBundles/tuls.unity3d"; #else path = "tuls.unity3d"; #endif WWW www = WWW.LoadFromCacheOrDownload( path, 5 ); yield return www; if(www.error != null) Debug.Log( www.error ); else Debug.Log( "succes" ); AssetBundle bundle = www.assetBundle; } But when i try to load a level Unity will crash: Code (csharp): Application.LoadLevel( "Dan Gun" ) [Edit] Just dawned on me that i'm trying to load a flash assetbundle; Trying with a webplayer one [Edit2] Yup! That was the culprit. It works in the editor now. Time for some flash.
Here's a very quick/basic example project which shows how asset bundles work for Flash export. I've included in the project some example source to build and load the asset bundle. If you run BaseScene.html in the BuiltExample folder and click the GUI button, that will load the bundled scene. View attachment $AssetBundles-Scenes.zip
I see. At any rate i can load asset bundles now, but there seems to be a size limit. Loading an assetbundle over 200mb times out in flash.
Hi there. thanks so much for your demo files cat. problem is i can load the swf at runtime but how do i go about exporting the bundledScene script in the first place? in the example if i change the paths within ExportSceneBundles.cs (to build/) and build the project it does not re-export the swfs into that location... thanks for any help b
that will be no problem in reality. Cause users will have closed and cursed your games long before that happens as 200mb takes eternities to download every time again Those are two different things. BundleScene creates streaming scenes, they are not flash players nor are they even able to do somehting on their own (they contain no code or shaders). You still need to build a normal flash build that has the code and 'core project' in to load these scenes etc
For anybody who has the same issue - for me it was the RAM. I had deactivated the paging file in Windows and the out-of-memory error seems to be silently ignored by the flash exporter. Adding more RAM (resp. increasing the page file) solved the problem.