- Home /
Materials with built-in shaders from assetbundle objects not assigned
Hey folks,
I recently updated from 4.1.2 to 4.3 and have a strange problem.
I export several objects as assetbundle and all objects that use built-in shaders (e.g. Unlit/Texture) appear to not have a material assigned. As if it wasn't exported within the AssetBundle.
Now I've noticed the new project settings 'Graphics' where you can select several shaders that should always be included. Adding the shaders fixes the problem. But is this really the desired approach? Do I have to add every built-in shader that's used within an assetbundle?
I am also running into this same issue. Loading assetbundles in the editor results in most materials being displayed in pink as though the shaders are missing. They work perfectly fine when built/run on device though. After doing a bit of reading online, it seems the shaders are compiled for the target platform within the assetbundle, so this could be the cause of the missing shaders in editor. Strangely though, this has never been a problem in previous versions of Unity so I am unsure if 4.3 has changed the support for this or if "some wires got crossed" when upgrading the project to 4.3. It would be great if there were some solution to this as it makes testing/debugging within the project rather difficult and time consu$$anonymous$$g without the use of the editor to do so.
As a really horrible and inefficient solution, one could always perform something like "Shader.Find()" on bundle load and then do some search/replace for the shader references. This does seem to solve the problem, but I don't understand why it is suddenly necessary in 4.3 when the issue has never occurred previously. Perhaps there is some editor setting that I am not aware of or a different method now for creating the assetbundles.
Answer by dhawalbanker · Mar 05, 2014 at 07:36 AM
This might be, because shaders are packaged with the asset bundles.
Check this link for more details: http://forum.unity3d.com/threads/144014-Custom-Shaders-and-Asset-Bundles-on-iOS