Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Reducing Build File Size - Assets only 1.8gb yet build is 8.5gb??

Discussion in 'General Discussion' started by Footlight14, Nov 24, 2017.

  1. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    HI,

    I have a predicament, my build for my game is currently at a massive 9 gig, yet the entire assets are only 1.8 gig. My library folder holds a whopping 19 gig, mainly found in the metadata folder (8 gig) and the PlayerDataCache folder (9 gig).

    I have tried deleting these folders to varying results (mainly that unity crashes or the build is missing stuff).

    Are there any particular folders/filed that can be deleted, or is there another way to reduce the file size/find out where the extra 7 gig is coming from?

    Thanks!

    James Lightfoot
     
  2. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    2,984
    Fera_KM likes this.
  3. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
    Which platform?
     
  4. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    Mac and PC build
     
  5. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
    In that case you should just be able to look at the files on disk. Try grabbing a tool like altWinDirStat and point it at the folder with your build in it, see where the space has actually gone.
     
    Ony, Mauri, Ryiah and 3 others like this.
  6. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    The library folder is whack. Has a tendency to keep unused stuff and balloon in size.

    Copy the project folder to another location. Remove the library folder. Open the project in Unity. Double-check that functionality is not disturbed. Build and enjoy.
     
  7. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
    The size of the Library folder has nothing to do with the size of a build.
     
    angrypenguin and Ryiah like this.
  8. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,793
    Go through any Resources folders and eliminate anything that does not belong in the build from them. Also remove any .dll's that are not being used. I did this recently and went from 500MB to 22MB on a build.
     
    theANMATOR2b, dogzerx2 and Ryiah like this.
  9. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Ah, my bad.
     
  10. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    Where is the extra 7 gig coming from then in your opinion?
     
  11. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
    You've not shared any information about the actual files on disk, so I have no idea.
     
    angrypenguin, dadude123 and Peter77 like this.
  12. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
  13. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,657
    The Library folder - still - has nothing to do with your Build as @superpig stated. It just contains files that are needed by/for the Unity Editor.
     
    angrypenguin likes this.
  14. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
  15. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    ok, i hear you. my assets are 1.8 gig but my build is 9 gig, any ideas what else i should be looking for that's adding this extra gigs on?
     
  16. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,244
    Describe your assets. My guess is all of them are compressed and get decompressed for the build.
     
  17. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,657
    The problem is that we don't know why your Build is that large. One of your used Assets could cause this, but which one? You could give the Asset "Build Report Tool" that @ShilohGames mentioned a try or use the program "altWinDirStat" for which @superpig gave you a link.
     
    angrypenguin likes this.
  18. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    ok thanks, I will try the Build Report Tool asset and get back to you. Other one doesn't seem to work on my MAC. Cheers
     
  19. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
  20. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    however, when i click on the textures folders within my assets, they certainly do not add up to the size the report is calculating?
     
  21. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,657
    You have almost 8GB of textures. Try using a compressing format that reduces the file size, but not heavily impacting the quality of the textures itself.
     
    theANMATOR2b likes this.
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,505
    Perhaps textures in your assets folder are in a compressed format, like .png?
     
    angrypenguin and Mauri like this.
  23. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    They are all .png's as I need them to be this rather than jpg. I didn't realised these are a compressed format?
     
  24. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    I guess under "compressed" people should rather think of something like .dds instead of .jpg. .jpg has lossy compression. There's other texture formats that allow much more efficient compression without loosing quality.

    What I'd want to know, what else can be done to reduce build size on PC?
     
  25. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,444
    Files under the "Assets" directory do not reflect the size of the imported asset. Textures under the Assets directory are converted to a proprietary format for the selected target platform.

    Using png is perfectly fine as it uses loss-less compression, but be aware that it's the source texture/asset and NOT what ends up in the build. Unity converts this png texture to its own format during import and generally stores the result in the Library folder.

    The size of the imported texture, this is what ends up in your build, depends on the selected Texture Import Settings, such as eg "Max Size" and "Compression" and DOES NOT depend on the format or size of the source png asset.

    If you you have a 2048x2048 png texture with very few colors, it might be just a few kilo bytes in your Asset directory. However, if it uses "Uncompressed" in the Texture Importer settings, the imported texture might become 21 MB.

    I recommend...
    • Check all Texture Import Settings and make sure textures are properly configured in terms of size and compression format.
    • To further reduce the build size, enable LZ4 compression in the build settings window.
     
    Last edited: Nov 28, 2017
    theANMATOR2b likes this.
  26. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
  27. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    Thank you, please see images here for all my .png settings in Unity project:

    https://www.dropbox.com/sh/ryhtnjxyswzt2qu/AADockgMy5HRf7B2kh4H857ma?dl=0

    Should I change these settings?

    Cheers
     
  28. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,444
    According to the screenshot, it displays the following warnings:
    This means, Unity cannot compress the texture and falls back to an uncompressed format to make it at least "work".

    POT stands for "power of two", which means the size must be 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, ... (you get the idea).

    The second warning is about DXT compression, which works on 4x4 pixel blocks. If either the width or height is not a multiple of 4, DXT fails.

    According to the screenshot, you seem to have at least these options:
    1. Use the "Non power of 2" setting and select something other than "None". I'm not sure whether this works for sprites, it might cause references to this texture to be lost. Backup your project first.
    2. Untick the "Generate mip-maps" checkbox. This has a significant impact on the visuals, so it might not work for many textures.
    3. Select a "Max Size" that makes sense. The default is 2048, but depending your assets, a smaller resolution might be fine as well.
    4. Reauthor your textures to meet the technical requirements. Technical requirements are met when Unity does not display any warning anymore.
     
    Last edited: Nov 28, 2017
    theANMATOR2b likes this.
  29. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
    Also, try enabling Crunch compression. It should have no impact on the visual quality of your textures, but should make them smaller on disk.
     
    theANMATOR2b likes this.
  30. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    I'm also going to try changing my files from 2048 to 1024, i have tried all in one scene and cannot see any change in resolution. I assume this will have a massive effect on file size? Then I will consider turning off mip maps
     
  31. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,444
    Your first priority should be to get rid of the texture warnings. That's most likely what will cause the most reduction in size.
     
    angrypenguin likes this.
  32. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    I see. the problem is, no one told me about the power of two! (This is my first game) so for my thousands of pngs, I haven't considered this!

    I tried removing the power of two to something other than none, but you were right, and it removed my sprite

    So you think I should untick generate mip maps for sure then?
     
  33. Footlight14

    Footlight14

    Joined:
    Mar 15, 2016
    Posts:
    27
    Or should I just bite the bullet and re link my sprites with the POT turned to something other than none?
     
  34. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    If you have sprites (not "raw" textures), then maybe you could pack all your sprites into an atlas.
    Sprites atlases are always made to be a power of 2. So that should work really well for you.

    That way you can bypass the problem of changing the image sizes - at least for now, or until your next game...
     
    theANMATOR2b likes this.
  35. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
    If you're not scaling your sprites down from the size at which they have been authored, then turning off mipmaps shouldn't cause you any problems, and will make the textures about a third smaller.

    That said, I think you might also be able to solve the POT issue by turning on the sprite packer.
     
    theANMATOR2b likes this.