我的 shader 很简单,就是一个 tiling and offset 制作滚动效果

然后我想用一个脚本控制 speed

但是实际运行没有起效果
一开始我看的这个,然后用的 sharedmaterial
https://forum.unity.com/threads/having-trouble-getting-a-material-setfloat-to-work-on-custom-shader-i-wrote.846451/

也不行
然后看到
https://forum.unity.com/threads/setfloat-doesnt-work-on-a-custom-shader.536107/
才发现是我需要使用 shader 中变量的引用名而不是变量名


这回就好了

本文介绍了在Unity中使用ShaderGraph和FlowCanvas制作滚动效果时,遇到通过脚本设置shader动态参数SetFloat无效的问题。通过研究Unity论坛上的帖子,作者发现必须使用shader变量的引用名而非变量名才能正确控制速度。解决问题后,shader的滚动效果得以实现。
最低0.47元/天 解锁文章
4万+

被折叠的 条评论
为什么被折叠?



