AssetBundleManager Shaders broken?

I’m working on an app which contains a main game and several minigames as well. I’m trying to separate the mini games each into their own asset bundle and store them on our server. I’ve downloaded Unity’s AssetBundleManager plugin for this task.

Each minigame is it’s own scene and I’ve built the asset bundles by allowing the AssetBundleManager to automatically select the dependencies. I’m building for iOS and I’ve uploaded the bundles to a server. Once I’ve built the game for my device (iPad 2) I load the assets using a script very similar to what’s included in LoadScenes.cs. It seems to download the assets and open the scene just fine.

The problem is that I believe many of my shaders are broken at this point. The terrain in one scene is broken and the standard shader also seems to not work in some instances. I’m seeing a few parts where the mesh is invisible and other parts where the mesh is that pink colour you see when the material doesn’t have a texture.

In the editor, I’ve tried opening the same scenes after downloading from the server and although they were broken at first, I was able to fix them by simply adding the relevant shaders to my “always included shaders” and rebuilding the assets. When they didn’t work I was able to see the correct textures and shader name in the inspector window on an impacted model. When I reselected the shader, the model loaded fine.

I also should point out that everything works fine on my iPad 2 when I load these scenes normally and not from an asset bundle I am trying to get my build size down though.

59959--droneshooter2.jpeg

Looks like your problem appears because you are using the same set of shaders for all your materials. At the AssetBundles build time, you have to move them into a separate AB which will be a dependency for all the other ABs and will have to be loaded prior to all the other asset bundles and assets.

While I’m sure that conflicting shaders is what caused my problem, I’m able to get everything to look fine by unchecking “Strip Engine Code” in the build settings.