Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Huge build size and very long build time. Why ?

Discussion in 'Editor & General Support' started by IndieMarc, May 26, 2020.

  1. IndieMarc

    IndieMarc

    Joined:
    Jan 16, 2017
    Posts:
    195
    Hi, I'm trying to build a Android game with Unity. I've had other projects of similar size before but this is the first project that act like that. The build size in editor log is huge and building time takes more than 30 minutes, mostly compiling shader variants.

    From the Editor Log:

    Textures 81.4 mb 15.7%
    Meshes 26.2 mb 5.1%
    Animations 2.9 mb 0.6%
    Sounds 25.2 mb 4.9%
    Shaders 9.6 mb 1.8%
    Other Assets 3.7 mb 0.7%
    Levels 354.4 mb 68.2%
    Scripts 1.9 mb 0.4%
    Included DLLs 13.3 mb 2.6%
    File headers 805.2 kb 0.2%
    Total User Assets 519.4 mb 100.0%
    Complete build size 1349.8 mb

    Why is the "Complete build size" so much higher than the "Total User Assets " ?? Also the "Levels" size seems a bit high but we only have around 10 scenes with reasonable sizes.

    For the build time:
    While building it seems to be stuck most of the time on "compiling shader variants": (At least 100K+ i would say, but i don't know where I can see the total, since it only shows each individual one, for example "Trees - Standard: 500 of about 5000" and then restart the count with the next shader).

    I do not have any shader that I coded. They are all standard shaders or packages, and the variants during the build time seems to be mostly on standard shaders. So its not shaders I can edit.

    Any idea what would cause those issues? I've searched a lot and tried to compress textures, audio and everything already. But I don't seem to find why its taking so much time and space.

    Thank you!

    Edit: Here are the Unity packages I use:
    Ads 2.0.8
    Mobile Notifications 1.0.3
    Package Manager UI 2.0.8
    Post Processing 2.3.0
    TextMesh Pro 1.4.1
     
    Last edited: May 26, 2020
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,214
    Sounds like you might be building a bunch of shader variants that you don't need in your build. I'd search for options for stripping out shaders you don't need. Unity usually does a lot of that for you. Do you have terrain in your build? Or do you know why you've got all those tree shaders? I'm not sure what "Trees - Standard" is coming from. Is that from an Asset Store asset? Or is that standard Unity terrain stuff?
     
  3. IndieMarc

    IndieMarc

    Joined:
    Jan 16, 2017
    Posts:
    195
    Hey thanks for your reply!

    I tried to disable a lot of options in the graphics settings and quality settings already but its still like that. Do you know how I could strip the useless shaders?

    The materials are from varied source. But that Tree example is from the asset store and its using the "Standard" unity opaque shader with a texture on it.

    I do not use Terrain no.
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,214
    Are you using the standard built-in renderer? Or HDRP or URP?
     
  5. IndieMarc

    IndieMarc

    Joined:
    Jan 16, 2017
    Posts:
    195
    Standard !
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,214
    Have you looked through the following to see if any applies to you?
    https://docs.unity3d.com/Manual/OptimizingShaderLoadTime.html
    https://forum.unity.com/threads/compiling-shader-variants-taking-ages.527724/
    https://www.reddit.com/r/Unity3D/comments/brmu70/psa_are_your_builds_taking_hours_and_sitting_on/

    To help triangulate this, I'd probably try to build a smaller portion of your game, with just a single simple scene, and make sure it builds quickly. Then add more scenes until you find specifically what's responsible for the issue.
     
    IndieMarc likes this.