• 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 /
avatar image
3
Question by JamesRigby · Jan 23, 2013 at 04:18 PM · assetbundle

Is it possible to save a compressed asset bundle to disk in uncompressed form.

I am working on a game where I have an asset bundle for each level. The idea is that these will be downloaded and saved to disk the first time the user plays a level. These asset bundles contain a number of scenes, and are about 50MB in size if compressed and about 350MB in size in uncompressed form.

From what I have read so far it looks like I have two options on how to load these asset bundles.

Option 1: Compressed form.

In this option I download the asset bundle to disk in its compressed form. Then, when I want to use it I do:

 m_file = new WWW(@"file://<path to file>");
 m_assetBundle = file.assetBundle;

Then I load my scenes as I need them

 Application.LoadLevel("Scene1");
 ...
 Application.LoadLevel("Scene2");

When I return to the main menu I do:

 m_assetBundle.Unload(false);
 m_file.Destroy

The problem with this method is that my 50MB asset bundle needs to be in RAM the whole time, which is a pretty big overhead.

Option 2: Uncompressed form

In this option I have created my asset bundle in uncompressed form (350MB) and have downloaded it to the disk.

When using I do:

 m_assetBundle = AssetBundle.CreateFromFile("<path to file>");

Then I load my scenes as I need them

 Application.LoadLevel("Scene1");
 ...
 Application.LoadLevel("Scene2");

When I return to the main menu I do:

 m_assetBundle.Unload(false);

This option gives much better memory usage (there is no 50MB overhead) but the user has to download a 350MB asset bundle.

Question

Is there a way to combine the best of these two options? Can I download my asset bundle in compressed form (50MB), uncompress it, and save it to disk in the uncompressed form (350MB). Then I can use the asset bundle directly from disk by using AssetBundle.CreateFromFile().

Many thanks

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
0

Answer by ryba · Jan 24, 2013 at 10:17 AM

Let users download compressed asset bundle, then if user try to open this asset bundle in your game, let the game uncompress it, save uncompressed assets on specific directory and remove compressed bundle.

You could also pack asset bundles into self extracting archive with extraction script, but id prefere first approach - self extracting scripts can lead to some problems, also forcing users to download and run binaries from the internet is not really elegant.

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 JamesRigby · Jan 24, 2013 at 10:20 AM 1
Share

Thanks for your answer. Could you tell me how to uncompress a compressed asset bundle?

avatar image ryba · Jan 24, 2013 at 11:12 AM 0
Share

Well, that depends on how are u compressing your bundle

avatar image JamesRigby · Jan 24, 2013 at 12:46 PM 1
Share

The bundle is compressed using Unity's own compression - i.e. by building using BuildPipeline.BuildStreamedSceneAssetBundle(). The uncompressed version is built using BuildPipeline.BuildPlayer(scenes, path, target, BuildOptions.UncompressedAssetBundle | BuildOptions.BuildAdditionalStreamedScenes ).

avatar image furic · Mar 11, 2015 at 04:56 AM 0
Share

I ran into the same problem, did the author solve it? Can you post the solution here?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to import the object from server to unity 2 Answers

Whats the difference between an Object and A GameObject? 2 Answers

How to load Assets as GameObjects? 1 Answer

Object parent Asset Bundle 1 Answer

Streaming scenes in assetbundles 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