UnityAndroid加载AssetBundle包时Shader遇到的问题

一些注意事项

Always Included Shaders:Proejct Settings --> Graphics --> Always Included Shaders

  1. 自定义的Shader都要加入到Always Included Shaders中。防止打包之后丢失Shader
  2. Unity自带的Shader,在打包的时候并不一定都会随着Unity打包出去,一切看Always Included Shaders里的设置。
  3. Unity自带的standard shader尽量不要用,因为他的变体太多,当你在Graphics里添加这个Shader之后,打包会非常慢。
  4. 在编辑模式下加载Android的AssetBundle包会显示错误,并且修改材质参数,效果也不会修改。打包在什么平台的AssetBundle包,就在什么平台来加载AssetBundle包,才能保证效果正确。(在编辑模式加载加载移动端的AssetBundle包,只能用来验证资源是否缺失,并不能验证显示效果)。
  5. Shader的依赖性低,大部分都是被依赖,尽量打成单独打AssetBundle包,避免之后预制体们打包,每个AssetBundle包都会包含这个Shader。(注意Shader里面引用的 .cginc 的文件)

原文链接

https://blog.csdn.net/weixin_45034929/article/details/118787894

实机测试报错:Desired shader compiler platform 18 is not available in shader blob.

错误描述

项目需求就是加载AssetBundle包资源,但Android项目实机测试时,部分Shader会失效,变成粉红色。连接Unity后监测实机时,会报错:

Desired shader compiler platform 18 is not available in shader blob.

其原因就是:目标平台的Griphic Api不支持
网上说需要手动添加一下:我这边测试之后并不好用,原因是该项目的需求限制,并不能在打包前将所需的Shader都添加上去。

解决方案

勾选Proejct Settings–>Player Setting–>Android–>Other Settings–>Auto Graphics API
如图,
前
后

参考链接

https://answer.uwa4d.com/question/614314ae8f8c834241aa4773

猜你喜欢

转载自blog.csdn.net/f_957995490/article/details/127445255