I’m using custom shaders with my asset bundle. At one point in the game, I let the user change the transparency of the 3d model by changing the transparency of the materials I manually referenced from the project file. Now, this used to work when I didn’t use asset bundles, since the model referenced materials from the project.
Now, when I built asset bundles, downloaded the model and tried changing its transparency then, it did nothing. Project materials changed but there was no change in the model itself. My guess is that the asset bundle created a copy of ALL textures and materials that my 3D model uses. Is that correct?
If so, will adding all model materials and textures to the asset bundle help solve that issue, or will I have to get materials from the model at runtime?
How do you change the material? Is material included in bundle or remains in project? Normally, bundle assets may reference assets in project by it’s guid and file id and it works okay for me.
I have a public array of materials inside a single script that handles their opacity. Those materials are taken from the project folder (by dragging them in the inspector).
The asset bundle only contains the 3D models and their prefabs.
In editor in play mode, when bundle is loaded and 3d model already instatiated, pause the editor, select model and click it’s material value field in the inspector. Unity will highlight a material in project folder, if it is referenced by mode so you can know which material instance is referenced by the model. If not, then you have copies in the bundle.
Probably this might be solved by rearranging files inside and outside the bundles or changing bundle build options? I have materials within bundles they reference shaders in project and it works okay. Maybe creating a separate bundle for your materials will help. If you will load materials into your list from the materials bundle also referenced by model bundles it should work as expected.