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

相关推荐
寂寞的船4 小时前
【Unity知识速递】第5期 Unity 6.2 深度解析:AI Assistant 登场,World Space UI 与 Sentis 全面升级
人工智能·ui·unity
寂寞的船6 小时前
【Unity知识速递】第4期 MCP for Unity:用 AI 自然语言控制编辑器
人工智能·unity·编辑器
淡海水7 小时前
09-04-内存-Unity原生对象生命周期
unity·c#·游戏引擎·gc
寂寞的船9 小时前
【Unity知识速递】第6期 URP性能优化完全指南:从内存到GPU的三维调优
unity·性能优化·编辑器
吴可可12311 小时前
富怡CAD二次开发指南
c#
1-1=011 小时前
C# IO和序列化
c#·.net·.netcore
寂寞的船12 小时前
【Unity Bug挑战】第10期 SerializeReference 内存泄漏之谜
unity·c#·游戏引擎·bug
CSharp精选营12 小时前
从控制台到「会动手」的 AI:用 Semantic Kernel 搭应用(小白教程)
c#·.net·ai agent·semantickernel·functioncalling
AGI_Eval1 天前
AI 3D生成技术:从“可用”走向“可靠”还有多远?
人工智能·3d
宝桥南山1 天前
.NET 11 - 尝试一下Blazor中的新特性SupplyParameterFromTempData
microsoft·微软·c#·asp.net·.net·.netcore