Lets say i imported a few packages, and each of these packages comes with some demos and extra textures/font/materials that i dont need in my project. Do I need to manually clean them up(remove them), or the size of the apk(android) wont be affected if im not using any of those unlinked scenes/demos/material/textures/FBX ?
Or are there any easy way for the unity to automatically remove unlinked stuff ?
If a package includes 20 scenes, but you don’t add any of them to your build, those won’t be included in your game. Likewise, only resources referenced by your included scenes (including scripts, textures, models) get included, so having a ton of unused assets doesn’t affect your game size.
The exception to this is the specially named Resources folder. Items in this directory or its subdirectories will be included in your build regardless of their inclusion in your scripts and scenes.
Are you sure about scripts/code? Because Unity has no way of checking when you are calling some code that is not referenced in the scene, it cannot simply just exclude code.
Code is usually attached to a game object. So when a code is not attached to any object in all the scenes with which you build, then it is not included.
I also had understanding that the script files will all be included for the same reasons as @blizzy mentioned. Looking forward if someone can clarify this.
This is what I read. But I do understand your point, since you can write class files and such. My assumption is there’s some kind of logic in place where a class file wouldn’t be included unless there was instance of that class being called.
I would have thought Unity could rely on its compiler to determine which scripts were necessary, but apparently it does not remove any scripts. It also does not remove anything in the Resources folder.
As that page mentions, though, scripts aren’t really that big a deal with file size. Unless you’ve imported every script you can find and don’t need them, I doubt scripts would be contributing much to build size issues.
Still, I agree that it’s surprising. The Resources thing is expected, and in fact, is the whole point of that folder.