Wait, so, this is intended?
We used to be able to exclude dependencies in 4.x, so we knew exactly what was in our bundles.
Now in 5.x, dependencies are always collected. Why? Why can’t we disable this? I no longer feel in control of what goes in to my bundle.
This is causing some real issues with shaders…! They turn pink, because, as mentioned above, the shader is precompiled for the target platform and included in the bundle (whether you like it or not!). This means that if I am testing in the Editor and have my platgorm set to Android, any asset bundle I load in the Editor will contain pink materials.
In 4.x, I used to exclude shaders from my asset bundles. My shaders were included in the resources folder and I was able to make the assumption that it would always be there. This way, I could exclude the shader from my bundle. When I loaded the bundle, it would use the shader already included in the application (and so it would always be the correct shader, since the shader was already compiled for the current platform whether it be windows, osx, ios or Android).
We can’t do this anymore. We need to build our asset bundles for all 3 platforms. Windows/OSX, iOS and Android.
This raises other questions too - for example, since the shader inlcuded in the bundle isn’t the exact same shader as the one in my project (it is a precompiled copy), does this break batching? Imagine if I had a custom diffuse shader which I used on all of my assets, and I had 10 asset bundles all containing different meshes/prefabs with materials that used this custom diffuse shader… Will this break dynamic batching since each asset bundle has its own copy of the same shader??
What about if I had a texture in my project that all of these prefabs were referencing? Forced dependency collection means that this texture will be copied 10 times (once for each bundle). So if I load and instantiate the prefabs in all 10 of these bundles, is this texture loaded into memory 10 times? (10x copies of the same texture).
Creating asset bundles which reference assets which are garunteed to exist in the project isn’t such a crazy idea either… Imagine a car game where each car was an asset bundle, and each car used the same shader or made use of some common texture. Or a card game like hearthstone where each card or theme of cards were an asset bundle and shared assets like the Mesh for the 3d card itself or made use of a common texture like the card backings… The forced dependency collection is just going to double up on all these assets…?
@Graham-Dunnett could you shed some light on this?