Home > Software engineering >  Can I reduce the default unity build size anymore
Can I reduce the default unity build size anymore

Time:09-22

Question Overview

I have a unity Andriod empty project with no scene added in player build. when I build my project it takes taking 16.8 MB size. Here is the build report of the unity project:-

Build Report


Actual Question

As you can see in the build report DLLs are taking 13.3 MB which is the most of build size.

Can I reduce this project build size anymore?

Ambiguities about unity build

I have read from unity docs, that Unity only includes those files in the build which is referenced in your scene but in this case, unity is also including files from the packages folder if packages are part of the build should I have to delete those packages? those packages without them, my project can remain alive like Rider editor, VS code, and maybe some editor tools.

Unity Assets and Never Used Code

Some developers like me cannot create everything from scratch that's why we use Unity Assets but unity assets comes with lots of code and also some unnecessary files for the project although these files can help users to understand all functionalities of this asset like pdf files, package.json, and others. should I need to delete these files before the final build or does unity automatically not include these files as a part of the build?

As scripts are the main part of the unity project sometimes we add lots of scripts from our utilities to make life easier and most likely at the end of final the project we have lots of functions that are not used by us but they are still part of these scripts like some static functions or script that's are not referenced Should I have to worry about that and delete all unnecessary code before the final build. if not please explain how it complies under the hood?

Final Words

I know these questions are basic but many beginners like me have these kinds of ambiguities in their minds please answer these questions in-depth and also provide some resources to research if needed and also share some personal tips to make the build concise.

CodePudding user response:

I'm not sure if that represents the "Included DLLs" but in the "Package Manager" window, you can go into the "Packages: Built-in" tab and "Disable" some of the Unity default features.
But doing so will trim some Unity's core feature so be careful.

If you build for Windows, in the "_Data" folder, you can check in the "Managed" and "Plugins" folders which DLLs are included. In the Android build, you can be sure that there will be Android equivalent.
And not sure about that but Apk file may be archive, you can try to explore them using 7zip to search for included files/DLLs.

About packages, yes, they are included in your build, at least those who got a "Runtime" part, Editor scripts are excluded. So yes, Rider or VS packages are probably excluded.

About scripts, every scripts, in your "Assets" or from Runtime packages, are included, in separated DLLs.
Others assets (in packages or "Assets") are only included if referenced (by scenes or prefabs) or placed in a "Resources" folder, so no, the documentation .pdf file will most likely not be included in the build.
(There is also the special "StreamingAssets" folder, that will just copy as-is the files next to the build, no compilation/compression)

And about unused code parts, they are included, there are multiple way a method could be called indirectly (Unity message system, Reflection, Unity Events) so there is no way to be sure that a method will never be called at compilation time.

  • Related