Unity build with over 70% taken up by File Headers
Asked Answered
M

1

6

Last night I was working on current Unity project and noticed when I build the File Headers make up over 70% of my build space. I read on the unity docs that this should not be the case.

Have searched the web on how to reduce this but got nowhere. Can anyone suggest a good approach to reducing this figure?

I have tried updating to the latest version of Unity and tried switching off Static Lightmaps, but neither has made a difference. Each time I build the project the Header Files seem to grow in size?

Within my resources folder (which is only 3 MB in size) I probably have:

  • 12 images
  • 7 materials
  • 45 prefabs.

Here is a photo of my issue:

enter image description here

And from my Editor.log:

Build Report
Uncompressed usage by category:
Textures      34.4 mb    15.6% 
Meshes        1.5 mb     0.7% 
Animations    2.0 mb     0.9% 
Sounds        384.9 kb   0.2% 
Shaders       4.7 mb     2.1% 
Other Assets  1.8 mb     0.8% 
Levels        3.1 mb     1.4% 
Scripts       1.1 mb     0.5% 
Included DLLs 4.1 mb     1.8% 
File headers  167.6 mb   76.0% 
Complete size 220.6 mb   100.0% 

Used Assets and files from the Resources folder, sorted by uncompressed size:
 11.3 mb     5.1% Assets/Realistic Terrain Collection/Terrains/Terrain1/Low Resolution_1.asset
 6.0 mb  2.7% Assets/Realistic Terrain Collection/Terrains/Terrain3/Low Resolution_3.asset
 4.6 mb  2.1% Resources/unity_builtin_extra
 1.3 mb  0.6% Assets/Town Creator Kit LITE/Textures/Buildings_Map_1A.png
 1.0 mb  0.5% Assets/Lava_Flowing_Shader/Textures/lava2.png
 658.0 kb    0.3% Assets/_Project/LoadingScreen/FWC_Logo.png
 412.9 kb    0.2% Assets/Fantasy Wooden GUI  Free/normal_ui_set A/UI board Small  stone.png
 384.2 kb    0.2% Assets/_Project/_Scenes/SnowyPeaksLevel/ReflectionProbe-0.exr
 384.2 kb    0.2% Assets/_Project/_Scenes/OutOfPlay/ReflectionProbe-0.exr
 ...
Modulator answered 22/3, 2018 at 13:49 Comment(0)
T
2

This shouldn't happen with this amount of files. First thing you should check is: Are you sure the assets you talk about (12 images, 7 material, 45 prefabs) are in the resource folder and not in the asset folder? The file header size depends on the amount of files in the resource folder only. Check the content of the resource folder again (just in case)

If you have a versioning system in place (git or others), you can try to open a clean version of your project. Checkout the project without the without .meta files. Let unity build the whole project and check the size in this new folder. (If you don't have a versioning software, you can still make a clean project and copy your scenes and assets manually, without .meta files)

If the size is still big, check if you have unnecessary static prefabs (static checkbox in the object). I don't know the technical reason for this but it was a solution for this guy

Quoting the link:

This has been solved

30 of the 36 mb was solved by unsetting static on 2 prefabs, guess I was doing something wrong there. The last 6 was from a scene, I deleted everything in the scene and the 6 mb was still there in the file headers, so I copied everything over to a new scene and deleted the previous scene. 6mb gone.

I expect that just making a clean install will work in your case.

If none of this work, it might mean that these headers are necessary for the resource folder to load. In this case, a solution could be to switch to Asset bundles instead of using the resource folder.

Asset bundles are archive files that can contain Unity specific assets such as Prefabs, Textures, Meshes, and so on. It still allows you to load assets at runtime. This is the solution proposed by Unity in this thread

Quoting the answer from a Unity dev in the link above

I think there is no way to decrease the file header size without decreasing the amount of files in Resource Folders. So my suggestion to continue using file paths from database is to migrate to a different solution using local assetbundles instead using Resources folder, you still can use the file path to load the asset from Assetbundles.

If this seems like a nice solution for your use case, here is the manual for Asset Bundles

Tubular answered 26/3, 2018 at 8:48 Comment(1)
Thanks for reply. My assets are inside my 'Resources' folder but that is inside my 'Assets' folder. I think that is the way it should be? My resources folder is 8.4 MB only.Modulator

© 2022 - 2024 — McMap. All rights reserved.