• 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
Question by Brett Juilly · Jun 25, 2010 at 11:22 PM · optimizationassetsscenescompresseduncompressed

How can I tell the COMPRESSED size of assets in my streaming web player build?

I'm optimizing my project. The Editor Log shows the compressed size of each scene, but only the uncompressed size of each asset. I want to identify the biggest COMPRESSED assets and optimize THEM!

Comment
Tetrad
qJake

People who like this

2 Show 0
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

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Lucas Meijer 1 · Jun 26, 2010 at 12:36 AM

Right now, only manually. as in, make a build with something, then make a build without that something, and then count the difference.

The uncompressed sizes are a decent first step though. usually scripts and dll's compress quite a bit better than textures/models/animations.

Comment
jonas-echterhoff
Bunny83
liortal

People who like this

3 Show 0 · 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
Best Answer

Answer by jonas-echterhoff · Jun 28, 2010 at 02:12 PM

Lucas is correct. Also, note that there is technically no way to reliably report compressed sizes of assets so that the sum of those is the total size of the compressed data.

The reason is that all data compression algorithms work by removing redundancy in the data. So, for example, if you had two assets, which are exactly the same, the compressor would be able to compress those better then compressing each individually, because it could basically just store the data once. But then, what would you report as the compressed size of each of them?

Comment
Brett Juilly
Bunny83

People who like this

2 Show 1 · 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 Bill-Robinson · Dec 01, 2014 at 11:49 AM 0
Share

Does it really identify identical assets? Do you have any evidence for this?

avatar image

Answer by Tommynator · Apr 24, 2012 at 09:32 AM

I just had the same problem and fixed it with this little snippet:

 private static void GetCompressedFileSize()
 {
     string path = AssetDatabase.GetAssetPath(Selection.activeObject);
     if (!string.IsNullOrEmpty(path))
     {
         string guid = AssetDatabase.AssetPathToGUID(path);
         string p = Path.GetFullPath(Application.dataPath + "../../Library/cache/" + guid.Substring(0, 2) + "/" + guid);
         if (File.Exists(p))
         {
             var file = new FileInfo(p);
             Debug.Log("Compressed file size of " + path + ": " + file.Length + " bytes");
         }
         else
         {
             Debug.Log("No file found at: " + p);
         }
     }
 }
Comment
TheCheese
AnomalusUndrdog
CanisLupus

People who like this

3 Show 3 · 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 TheCheese · Nov 29, 2012 at 06:48 PM 1
Share

In Unity 4 change the "cache" section of string p to "metadata"

avatar image Bill-Robinson · Dec 01, 2014 at 11:36 AM 0
Share

I don't think that really does it, I got a size LARGER than the original for mine.

avatar image SagoRich · Mar 22, 2018 at 07:51 PM 0
Share

I had some luck with using the metadata folder, and not just the guid, but guid.resource. For audio files, the size of the .resource file seemed to match what is reported in the inspector as the compressed size. e.g.

 public static long GetCompressedFileSize(string guid) {
     string assetPath = AssetDatabase.GUIDToAssetPath(guid);
     if (!string.IsNullOrEmpty(assetPath)) {
         string p = Path.GetFullPath(string.Format("{0}../../Library/metadata/{1}/{2}.resource", Application.dataPath, guid.Substring(0, 2), guid));
         if (File.Exists(p)) {
             return new FileInfo(p).Length;
         }
     }
     return 0;
 }

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to remove duplicate models in assets without breaking scenes 0 Answers

Android Loading scene / loading assets problem 1 Answer

ResourceManager Class Referencing Assets? 1 Answer

Is it possible to add new scenarios and therefore new scenes from a remote location without having to rebuild the app to integrate the new scenes and scene modifications? 2 Answers

Save current Scene in Assetsfolder 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