解决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"参数关闭。

相关推荐
武藤一雄8 小时前
C# 异步回调与等待机制
前端·microsoft·设计模式·微软·c#·.netcore
adogai10 小时前
unity mcp接入 实现一句话生成游戏!
游戏·unity·游戏引擎
mxwin11 小时前
Unity Shader 逐像素光照 vs 逐顶点光照性能与画质的权衡策略
unity·游戏引擎·shader·着色器
乱蜂朝王12 小时前
使用 C# 和 ONNX Runtime 部署 PaDiM 异常检测模型
开发语言·c#
CDN36012 小时前
游戏盾导致 Unity/UE 引擎崩溃的主要原因排查?
游戏·unity·游戏引擎
mxwin12 小时前
Unity URP 全局光照 (GI) 完全指南 Lightmap 采样与实时 GI(光照探针、反射探针)的 Shader 集成
unity·游戏引擎·shader·着色器
JosieBook13 小时前
【C#】VS中的 跨线程调试异常:CrossThreadMessagingException
开发语言·c#
追雨潮14 小时前
BGE-M3 多语言向量模型实战:.NET C# 从原理到落地
开发语言·c#·.net
mxwin14 小时前
Unity URP 溶解效果基于噪声纹理与 clip 函数实现物体渐隐渐显
unity·游戏引擎·shader
CheerWWW15 小时前
GameFramework——Download篇
笔记·学习·unity·c#