c# - Unity 2018.3 HDRP - 以编程方式更改材质颜色?
问题描述
我正在使用新的 HDRP/LitTesselation 着色器。
我想Base Color + Opacity
在运行时更改:
我将此代码添加到游戏对象的脚本中:
void start()
{
Color color = new Color(100, 50, 100, 150);
//Fetch the Renderer from the GameObject
Renderer rend = GetComponent<Renderer>();
//Set the main Color of the Material to green
rend.material.shader = Shader.Find("_Color");
rend.material.SetColor("_Color", color);
}
Hidden/InternalShaderError
但它会在着色器中产生错误。谁能指出我正确的方向?
解决方案
我通过如下修改这些行来使其工作:
rend.material.shader = Shader.Find("HDRenderPipeline/LitTessellation");
rend.material.SetColor("_BaseColor", color);
推荐阅读
- java - 如何在没有结果集的情况下填充 CachedRowSet 对象?
- tailwind-css - Tailwind 类 space-x 或 space-y 在 IE 11 中不起作用
- sql - 基于小时和时间的自定义范围字段
- c# - 使用jQuery ajax过滤mvc razor中的下拉列表
- python - 难以将元组转化为索引
- jquery - jQuery - 检测背景图像 url 是否是从 HTML 设置的
- spring - 硬编码值或外部属性优先于数据库池大小?
- python - 将python脚本的输出返回到bash变量
- keil - 带有 AXIM/ITCM 闪存的 STM32F7 VMA 和 LMA
- python - 熊猫:使用apply的明显类型不匹配