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 /
avatar image
2
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
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

3 Replies

· Add your reply
  • Sort: 
avatar image
3
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
Add comment · 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
2
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
Add comment · 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
3

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
Add comment · 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 $$anonymous$$e.

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Getting Scenes in Project From Editor 2 Answers

how to properly add custom scene(s) to a custom package in Samples~ folder? 0 Answers

How to optimize the assets for the android platform? 0 Answers

Optimize my game? 2 Answers

Loaded a scene from assets while working on my own, now i can't figure out how to get back to mine.... 0 Answers


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