Excluding Asset Folders on an Per-Build Basis?

We are working on a city model viewer for WebGL, so we want to keep our build sizes small to be accessible for as many people as possible. For every city model, we use a different scene instead of a new project to keep our codebase and workflow in sync, and to keep things uncomplicated, pretty self-explanatory.

We only include the scene of the respective city model in our build, which we then send to our clients for upload on their website. Now my question:
Is there an automated way (or a way which can be automated through further scripting) to exclude specific folders holding the textures and models of the other cities when building for one city only? We now have 3 cities in our project with around 30MB per city, and the more cities we have in our project, the more unused clutter every new build will have. For end users with a bad internet connection, that would be quite detrimental.

I of course know about the special folder Assets/Editor, to exclude assets from the build of a project, but is there a way to replicate this behaviour, or maybe a way to make a custom script which a) builds only with a specific scene and b) excludes assets from a list of given paths? Just throwing ideas around, as I am at a loss.

Unity doesn’t include unreferenced assets in builds. If you change the active scenes and make a build, only the assets referenced by those scenes will be included. The exception are assets placed in Resources folders, which are always included.

1 Like