So, I’d really love some way to script the creation of the data in asset bundle variants. Our current layout is to have different variants for different texture resolutions/compression settings; at load time, we select a variant for the device based on memory, screen size, etc. For the most part, our variants are only used for texture data.
However, given that we support 4 variant levels, this means 4 copies of every texture in our tree. This is error prone, wasteful of drive space, and increases caching time substantially. I’d really love to get rid of these completely, and only have one copy of each texture.
Recently I’m working on running on low memory devices on Android. This is problematic because of the lack of universal texture compression which supports alpha. If I want to use the variant system for this, it would be a 4x on all of my textures. So instead, I’m building versions of all of our asset bundles for each of the various texture compression formats on android (dxt, pvr, astc, etc). This basically works by switching the texture type and re-building the asset bundles for each format, which is also incredibly slow.
This has lead me to the idea of not using the variant system at all, writing a custom editor for textures which allows me to tag them with the needed data, then building one copy of the asset bundles for each variant/compression/platform combination (roughly 25 copies of my asset bundles). It saves me from having duplicate data in my tree, but will most likely destroy our build times and make our lives painful in new and undiscovered ways.
Ideally, I would be able to use the actual variant system without duplicating data or building multiple copies of the asset bundles. (ie: Single manifest per platform, variants for resolution - and extra variants for texture type on android). However, to do this, we’d need a different set of APIs that would allow the creation of these variants at build time. I posted an idea for how this might look here:
The basic idea is a callback when each asset is built into the bundle, which allows you to manipulate the data and it’s importer settings before it’s put into a bundle, or add it to multiple bundles/variants.