Does Unity pack all files from the project in the build?
It's probably a stupid question, but I'm just wondering.
Let's say you have 100 files in your Unity project, but your game only uses 50 of those files. So when you build the game, will Unity include all 100 files (used and unused) in the game build, or just the 50 that you used?
Answer by tanoshimi · Mar 07, 2016 at 01:43 PM
If they're referenced by an object instantiated in a scene anywhere, they'll be included.
If they're placed in the /resources folder, they'll be included.
If they're an "orphan" - placed in the assets directory but not referenced by anything or used anywhere, they won't be included in a build.
Thank you! That is exactly what I wanted to know. I released a small test game a few months back and realized today that there were still a lot of unused (copyrighted) placeholder files in the assets folder. But I'm pretty sure they aren't referenced anywhere.
"a scene anywhere" - does this mean that if you do not include a scene in the build, unity still packs that scenes objects?
Answer by Geoxion · Mar 07, 2016 at 03:34 PM
No, unity tries to be smart about it and pack the least amount of files. There are some exceptions though.
All files in resources and streamingassets folders will be included. Files from the Editor folders will not be included. All other files won't be included when they're not used.