Search Unity

Resolved Ideas about what is causing one level to build out at 7gig?!?

Discussion in 'Getting Started' started by Tset_Tsyung, Oct 5, 2022.

  1. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    Hey all,

    I've never had this problem before...

    My team and I working on a low-key sim that utilises a 4*4km terrain using Unity 2021.3.6f1. There are 'straight-from-the-asset-store' models (which means more drawcalls than I'd like) and some VR thrown in there as well.

    We did dabble with Lighmapping and occlusion culling, but removed all of that as they were of no use after testing.

    TLDR:The problem is that (ignoring the performance for now) the level in question is building out to be 6.9gig, takes far too long to load and hogs all the memory!!! How do I find out exactly what is causing this bloat?

    I've installed the Build Report Inspector, and am currently building again to get the editor log as well. But what should I be looking for?

    As always, kind regards to all,

    Mike
    UPDATE: Here's an excerpts from the Editor.Log - advise if more is needed:
    Uncompressed usage by category (Percentages based on user generated assets only):
    Textures 782.7 mb 75.9%
    Meshes 170.6 mb 16.5%
    Animations 663.4 kb 0.1%
    Sounds 7.4 mb 0.7%
    Shaders 9.7 mb 0.9%
    Other Assets 59.7 mb 5.8%
    Levels 0.0 kb 0.0%
    Scripts 309.8 kb 0.0%
    Included DLLs 0.0 kb 0.0%
    File headers 198.7 kb 0.0%
    Total User Assets 1.0 gb 100.0%
    Complete build size 7.7 gb
     
    Last edited: Oct 5, 2022
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,038
    What Unity version?
     
    Tset_Tsyung likes this.
  3. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    Apologies, we are using Unity 2021.3.6f.
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,038
    Do you use adressables or something like that?
    And do you use a Resources folder in your project?
     
    Tset_Tsyung likes this.
  5. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    No. We've never had a need to investigate them, and because its always full on pace (new project, straight after another, each one totally different. Have to get them out to the client in 1 month, maybe 2...) we just havent had time to look into what has not been needed for thale particular project in question. I have looked into them a bit in my own time, but didnt (and perhaps, mistakenly so) they wouldnt be suitable for this project.

    The problem with this project is that the client has to be able to zoom in to a ridiculous degree on their remot camera in the scene, so importing objects on the fly might not be possible without causing massive GC issues... right? Or am I barking up a wrong tree...

    Mike
     
  6. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,038
    Loading objects is about memory, not storage size. If you have a folder called Resources, all files in that will be included in builds
     
    Tset_Tsyung likes this.
  7. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    This still doesnt answer why one level is so big when, according to the editor log, there aren't enpugh assets to justify that size

    But to answer your point about a resources folder directly: we dont use one.
     
  8. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,038
    Maybe upgrade unity and delete the Library folder and build again?
    If it then still happens make a bug report
     
    Tset_Tsyung likes this.
  9. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,401
    check also StreamingAssets/ folder,
    try clear baked lighting if its still there (from lighting tab, the small dropdown arrow near bake)

    Also if baked colliders are enabled, that increases build size, but i think it should show in that stats..
    Check editor.log for the list of assets from biggest to smallest. (after build, if that build info plugin doesnt do that)

    also one time i had issue where copying objects from Scene A into new fresh Scene B helped reducing scene size.
     
    Tset_Tsyung and DevDunk like this.
  10. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    This is something we tried and had running at about 18:30 last night, minutes before your suggestion, ha ha. We didn't upgrade to a newer version of Unity, but we did delete the Library, Object & Logs folders before reimporting all and rebuilding. No Change :(

    There is an example of this in the OP - nothing is jumping out as a large asset. But I don't believe this includes Unity Combined objects... which brings me to the 'solution'


    This got me thinking, so I checking into it and realised that by setting the terrain and associated scenery objects to static, Unity was combining everything into a single mesh for Static Batching. This means that all the bushes that line the road are added, separately, to a baked mesh... all several thousand of them! This appears to be the issue.

    Our chosen solution: We've kept everything as static (changing the one flag will cause issues with prefab importing as there's so much in a 'nested prefab' architecture), but simply disabled Static Batching in the player settings. This has changed a 7gig built scene to a more manageable 97mb scene.

    Thank you for your assistance and replies. It is very much appreciated and helped me stay just this side of sane being able to bounce something off of you (no, seriously!).

    Again, thank you:D