解决EnableKeyword(“_Emission“)运行状态不起作用

我使用的是Standard Shader,一开始"_Emission"没有开启

当我运行下面的代码,可以看到Inspector窗口已经生效,然而物体本身并没有重新开始渲染,反射没有开启

cs 复制代码
public GameObject go;
// Start is called before the first frame update
void Start()
{
    var m = go.GetComponent<MeshRenderer>().material;
    m.EnableKeyword("_Emission");
    m.SetColor("_EmissionColor", Color.red);
    m.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;
    go.GetComponent<MeshRenderer>().material = m;
}

解决方案: "_Emisson"参数保持开启状态,通过更改"_EmissionColor"来控制反射,_EmissionColor为纯黑时,效果等同于"_Emisson"参数关闭。

相关推荐
yue00811 小时前
C#理论学习-WinForm实践开发教程总结
开发语言·学习·c#
星夜泊客12 小时前
Unity 游戏开发中的防御性编程与空值处理实践
unity·设计模式·游戏引擎
睡前要喝豆奶粉14 小时前
多表分页联查——EF Core方式和Dapper方式
c#·.netcore
格兰芬多呼神护卫15 小时前
python实现Latex格式的公式转OMML并写入word
python·c#·word
chao18984416 小时前
C 文件操作全解速览
服务器·c语言·c#
多恩Stone17 小时前
【3DV 进阶-5】3D生成中 Inductive Bias (归纳偏置)的技术路线图
人工智能·python·算法·3d·aigc
tealcwu18 小时前
【Unity踩坑】Unity测试用例命名空间错误解决方案
unity·游戏引擎·测试用例
月巴月巴白勺合鸟月半18 小时前
一个DevExpress的Docx文件处理的Bug的解决
c#·bug
.NET修仙日记19 小时前
第一章:从零开始构建你的第一个C#/.NET应用程序
c#·.net·.net core
地狱为王1 天前
Unity使用PP-MattingV2实现人像分割
unity·游戏引擎