Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by DDP · May 25, 2012 at 05:01 PM · optimizationflashweight

Exclude code from SWF

Hi,

I'm new to Unity and I'm using the Flash export. I want to have 1 swf file per level of my game.

When I look at the list of exported classes in the swf, I can see a lot of classes in the packages global, System and UnityEngine. I understand that those classes are required for the game to run.

I want to load these classes only once, but they are included on every swf that I export. Is it possible to avoid this waste of file weight?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by catburton · Jun 19, 2012 at 03:56 PM

If you wish to save file-size of your bundled scenes, you can use streamed scenes with push/pop dependencies to achieve this.

  1. Build a player from your main scene.

  2. Push dependencies

  3. Build any additional streamed scenes

  4. Pop dependencies

This will result in your main scene swf being its usual size but your streamed scene swfs will be much smaller.

Here's a quick example that you should be able to modify for your project:

 public class ExportSceneBundles : Editor
 {
     [MenuItem("Assets/Export Scene Bundles")]
     public static void Export()
     {
         System.IO.Directory.CreateDirectory("SceneAssetBundles");
         
         var options = BuildAssetBundleOptions.CompleteAssets;
         
         BuildPipeline.BuildPlayer(new string[]{"Assets/BaseScene.unity"}, "SceneAssetBundles/BaseScene.swf", BuildTarget.FlashPlayer, BuildOptions.None);    
         
         BuildPipeline.PushAssetDependencies();
         
             BuildPipeline.PushAssetDependencies();
                 BuildPipeline.BuildStreamedSceneAssetBundle(new string[]{"Assets/StreamedScene.unity"}, "SceneAssetBundles/StreamedScene.swf", BuildTarget.FlashPlayer);    
             BuildPipeline.PopAssetDependencies();    
             
         BuildPipeline.PopAssetDependencies();
     }
 }
Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DDP · Jun 22, 2012 at 12:01 AM 0
Share

Hi Cat,

Thanks a lot for your reply. We did use the asset bundles at some point, like you suggest in your response. But in the end, we used another approach for our project.

When making a project for Flash with Unity (we are using 3.5 right now) it's not a good idea to output multiple swf for the same project. You will end up with lots of duplicated stuff. It's a better idea to place all scenes inside of only 1 swf. For us, it was a big improvement. We used to have 25 swf 4$$anonymous$$b each (1 per level). Now, we are packaging all level together (1 level = 1 scene) and we have only 1 swf of 8$$anonymous$$b. So yeah, there had a lots of duplicated stuff!

Also, to improve the loading time, we start the Unity's swf downloading while the user is browsing the menus.

$$anonymous$$aybe there are even better practices for flash projects in Unity, but we didn't found them yet. Any comment/suggestion is welcome!

avatar image DDP · Jun 22, 2012 at 12:11 AM 0
Share

Hi Cat,

Thanks a lot for your reply. We did use the asset bundles at some point, like you suggest in your response. But in the end, we used another approach that we better for our project.

When making a project for Flash with Unity (we are using 3.5 right now) it's not a good idea to output multiple swf for the same project. You will end up with lots of duplicated stuff. It's a better idea to place all scenes inside of only 1 swf. For us, it was a big improvement. We used to have 25 swf 4$$anonymous$$b each (1 per level). Now, we are packaging all level together (1 level = 1 scene) and we have only 1 swf of 8$$anonymous$$b. So yeah, there had a lots of duplicated stuff!

Also, to improve the loading time, we start the Unity's swf downloading while the user is browsing the menus.

avatar image Bunny83 · Jun 22, 2012 at 12:20 AM 0
Share

@DDP: Don't post comments as answers. If you want to reply to a post, use the "add new comment" button below the post. If you want to answer your own question, post an answer, but only if it's intention is to answer the question.

Since you already accepted catburton's answer i guess it solved your problem.

avatar image catburton ♦♦ · Jun 22, 2012 at 09:01 AM 0
Share

@DDP - I'd be interested to know what was duplicated in each of your scenes to result in each swf being 4$$anonymous$$B in size. Perhaps if they are all sharing some common assets, which could be bundled into a shared asset bundle. It sounds like your solution worked well for your project, but if you did want to use the asset bundles, let me know and I'll try to help you work out why they were so large in size.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Flash raw animation data to Unity 0 Answers

Reduce AI processor weight 2 Answers

Unity large level size in build 0 Answers

Optimization unity flash 1 Answer

Add weight every time something enters trigger 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges