Unity shader打包Assetbundle之后自定义keyword失效问题

关于shader设置关键字有两种方法

#pragma multi_compile
#pragma shader_feature

multi_compile和shader_feature,唯一的区别在于shader_feature不会将不用的shader变体添加到程序中去

由于这个原因会导致shader_feature的变体不会打进Assetbundle里面,从而导致失效

解决方法

1.把这个变体shader放到include shader里面,不过每次打包都要把变体编译,打包慢没必要

2.把shader_feature用multi_compile替换

关于shader变体可以看看下面博客

https://blog.csdn.net/ecidevilin/article/details/52882400?utm_source=blogxgwz2

猜你喜欢

转载自blog.csdn.net/SnoopyNa2Co3/article/details/88998810