All objects loaded from assetbundles that use custom shaders appear black. Anyone else having this issue?
The shaders are definitely there, since I can fix the problem by calling the following script on the gameobject that has just been instantiated from an asset loaded from a bundle. The script simple iterates over all the shaders currently used on the asset, loads them by name, and reassigns it, but this should not be necessary.
public void RedoShaders(GameObject g)
{
Renderer[] allRenderers = g.GetComponentsInChildren<Renderer>();
for(int c = 0;c < allRenderers.Length;c++)
{
for(int i = 0; i < allRenderers[c].sharedMaterials.Length; i++)
{
if(allRenderers[c].sharedMaterials[i].shader.name.ToLower().Contains("custom/"))
{
Shader myshader = Shader.Find(allRenderers[c].sharedMaterials[i].shader.name);
allRenderers[c].sharedMaterials[i].shader = myshader;
}
}
}
}