x


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!

more ▼

asked Jun 25 '10 at 11:22 PM

Brett Juilly gravatar image

Brett Juilly
33 3 3 7

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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?

more ▼

answered Jun 28 '10 at 02:12 PM

jonas echterhoff gravatar image

jonas echterhoff ♦♦
9.8k 7 23 104

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jun 26 '10 at 12:36 AM

Lucas Meijer 1 gravatar image

Lucas Meijer 1 ♦♦
8k 19 43 85

(comments are locked)
10|3000 characters needed characters left

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);
        }
    }
}
more ▼

answered Apr 24 '12 at 09:32 AM

Tommynator gravatar image

Tommynator
381 3 4 11

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

Nov 29 '12 at 06:48 PM TheCheese
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x472
x281
x110
x10
x3

asked: Jun 25 '10 at 11:22 PM

Seen: 1342 times

Last Updated: Nov 29 '12 at 06:48 PM