Search Unity

Reducing filesize of build

Discussion in 'Editor & General Support' started by deLord, Aug 30, 2017.

  1. deLord

    deLord

    Joined:
    Oct 11, 2014
    Posts:
    306
    Hello

    I just realized Google Play will only allow 100 MB apks and since I have no idea yet how to use expansions yet, I try to get my project as small as possible.

    Which options do I have to make the filesize of a terrain smaller? Basically, most terrains dont even use any height and I already set the height resolution to 33 (the minimum).
    How can I compress fbx/model files? The "mesh compression" as mentioned by the doc I cannot find.
    How can I compress animations?
    Also, is there any way to see the COMPRESSED size of the build elements? I mean what does it help if it lists me an image as 2MB when compressed it is only 370kb?
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    Hi,

    You could use asset bundles to load those big files into app on first run..
    or try the splitting https://docs.unity3d.com/Manual/android-OBBsupport.html

    Can you show your build size log?

    its in the editor log, it shows things like:
    Code (CSharp):
    1. Textures      12.7 mb     1.$%
    2. Meshes        767.2 kb     1.$%
    3. Animations    0.0 kb     -1.$%
    4. Sounds        0.0 kb     -1.$%
    5. Shaders       2.5 mb     1.$%
    6. Other Assets  26.1 kb     1.$%
    7. Levels        6.5 kb     1.$%
    8. Scripts       621.2 kb     1.$%
    9. Included DLLs 3.9 mb     1.$%
    10. File headers  13.1 kb     1.$%
    11. Complete size 0.0 kb     -1.$%
    12.  
    13. Used Assets and files from the Resources folder, sorted by uncompressed size:
    14. 8.0 mb     1.$% Assets/sIBL Archive/LA_Downtown_Helipad_GoldenHour.hdr
    15. 2.1 mb     1.$% Assets/PostProcessing/Resources/Shaders/Uber.shader
    16. 1.3 mb     1.$% Assets/VikingVillage/Textures/Props/prop_skull_01_sg.tif
     
  3. deLord

    deLord

    Joined:
    Oct 11, 2014
    Posts:
    306
    Code (CSharp):
    1. Textures      117.8 mb     64.3%
    2. Meshes        11.3 mb     6.2%
    3. Animations    36.4 mb     19.9%
    4. Sounds        1.6 mb     0.9%
    5. Shaders       580.8 kb     0.3%
    6. Other Assets  5.9 mb     3.2%
    7. Levels        3.5 mb     1.9%
    8. Scripts       1.4 mb     0.8%
    9. Included DLLs 4.1 mb     2.2%
    10. File headers  613.5 kb     0.3%
    11. Complete size 183.1 mb     100.0%
    12.  
    13. Used Assets and files from the Resources folder, sorted by uncompressed size:
    14.  10.7 mb    5.8% Assets/prefabs/models/UnityWizard/WizardA.dds
    15.  10.1 mb    5.5% Assets/prefabs/GoblinArmy/Goblin_Baron.FBX
    16.  8.2 mb    4.5% Assets/prefabs/GoblinArmy/Goblin_Bandit.FBX
    17.  7.1 mb    3.9% Assets/prefabs/GoblinArmy/Goblin_Shaman.FBX
    18.  6.6 mb    3.6% Assets/prefabs/GoblinArmy/Goblin_Slave.FBX
    19.  3.5 mb    1.9% Assets/prefabs/models/UnityWizard/TheWizard.fbx
    20.  2.6 mb    1.4% Assets/prefabs/models/FemaleElementalist/FemElementalist.fbx
    21.  2.4 mb    1.3% Assets/scenes/Terrains/ter_smallRoad.asset
    22.  2.4 mb    1.3% Assets/scenes/Terrains/ter_rockyBasic.asset
    23.  
    I managed to reduce the overall size to below 90 MB now, since I realized the sounds can be heavily compressed with Vorbis quality 1/100. But still, there is a lot to optimize.

    Where can I find info on the asset bundles that you mentioned? Or is that the splitting (thanks for the link!)?
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    https://docs.unity3d.com/Manual/AssetBundlesIntro.html

    in short
    - select prefab, set assetbundle tag *i prefer doing bundles in separate project, so their extra files wont get included in build..not sure if thats good idea though
    upload_2017-8-30_21-50-17.png
    - run Build the AssetBundles script https://docs.unity3d.com/Manual/AssetBundles-Workflow.html *set target to android
    - copy bundle files to your server
    - load & instantiate bundles, some example at https://docs.unity3d.com/Manual/AssetBundles-Manager.html
    - after you have loaded bundle once, it should get cached on device
     
  5. deLord

    deLord

    Joined:
    Oct 11, 2014
    Posts:
    306
    I think I will try to avoid bundles as long as possible. Takes too much time go get into it now.

    Any ideas on compressing models, animations and terrains?
     
  6. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    Having mono sounds almost halves their file size, but is generally not noticeable on mobile, almost certainly not as much as reducing the quality. You could do both and reduce the file size even more.
     
    deLord likes this.
  7. deLord

    deLord

    Joined:
    Oct 11, 2014
    Posts:
    306
    19,4MB @ 1/100 Vorbis ---Force Mono---> 9,2MB
    nice :)
     
  8. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    can also build ARM only, instead of FAT, if that helps much on build size much.
    (and then upload them separately if want to..but read somewhere here that x86 androids are like 2% or less?)
     
  9. deLord

    deLord

    Joined:
    Oct 11, 2014
    Posts:
    306
    I have two questions about terrains.

    I figured since I cannot use 30 terrains because each will be at least 1-2 MB, making all terrains into 1 can drastically reduce the resulting filesize.

    Now the only question is: when my 1 super-terrain hosts all 30 segments and each scene will only show 1 segment (divided by nothing specially, just the position of the terrain will change per scene) will the other 29 invisible segments of the terrain impact the performance? Since it is the same object and heights generate triangles. Or will the unrendered triangles/terrain not decrease the performance?
    EDIT: OK, it does very negatively impact the performance. Is there a way to not do that? Maybe with some asset from the store or a nice script?

    Another question is, why does the filesize of a terrain grow when I just add textures? It does not grow with terrain size or when I paint onto it. That feels a bit strange to me. How can the terrain grow from 1 to 8 MB just by adding textures?
     
    Last edited: Sep 15, 2017
  10. Autonoma

    Autonoma

    Joined:
    Jul 21, 2013
    Posts:
    92
    How many textures did you add?
     
  11. TeohRIK

    TeohRIK

    Joined:
    Jan 22, 2014
    Posts:
    106
    Not sure you already did this or not, try to compress your texture in the import settings and disable mip map if you not using it