2
\$\begingroup\$

I'm going to make a release for my Unity game.

Does Unity include unused assets in build output? Would removing unused assets from a project reduce build size/Time?

I want to know if Unity packages all the assets to my build (which I would need to delete), or if Unity packages only the assets that are actually used in the game.

\$\endgroup\$
  • \$\begingroup\$ not very clear what your asking. could you explain it better? \$\endgroup\$ – Leggy7 Apr 15 '16 at 10:06
4
\$\begingroup\$

Unity just packs the thing that you are really using. So for example if you have 100 audio files and you just have one scene with one audio source where 1 audio file is assigned, then only this particular audio file will be delivered in your build. However when you have a script that has a reference to those 100 audio (in order to e.g. assign them randomly to the audio source), then all 100 files will be packed in the build.

Like DMGregory commented there is one exception: The "Ressources" Folder. All the files inside that folder will be packed in your build, since they are dynamically loadable at runtime, by name (so there is no direct reference in the scenes).

\$\endgroup\$
  • 2
    \$\begingroup\$ The one exception to this is assets within a folder named "Resources" — this special folder name tells Unity "I might dynamically load this asset by name, so make sure it's always included even if it's not referenced anywhere" — so make sure you keep only assets you're actually loading via Resources.Load in these special folders. Also, all scripts are always included. They're small, but if you want to shave off everything unused then you should delete scripts you don't need. \$\endgroup\$ – DMGregory Apr 15 '16 at 13:45
  • \$\begingroup\$ Yes, you are absolutely right. I adjusted my answer. \$\endgroup\$ – M156 Apr 15 '16 at 13:48
  • \$\begingroup\$ so you mean only assets will be packed that is used in any scene? \$\endgroup\$ – virtouso Apr 15 '16 at 20:26
  • \$\begingroup\$ Basically yes. Here and there are some exceptions. You can always see what is in your final build product by opening the editor log. \$\endgroup\$ – M156 Apr 15 '16 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.