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

相关推荐
Yorlen_Zhang19 分钟前
Python Tkinter Text 控件完全指南:从基础编辑器到富文本应用
开发语言·python·c#
不绝19132 分钟前
C#进阶:预处理指令/反射,Gettype,Typeof/关键类
开发语言·c#
zhooyu44 分钟前
C++和OpenGL手搓3D游戏编程(20160207进展和效果)
开发语言·c++·游戏·3d·opengl
大鹏说大话1 小时前
告别 MSBuild 脚本混乱:用 C# 和 Nuke 构建清晰、可维护的现代化构建系统
开发语言·c#
czhc11400756632 小时前
通信 28
c#
我的offer在哪里4 小时前
示例 Unity 项目结构(Playable Game Template)
unity·游戏引擎
bugcome_com6 小时前
C# 程序结构详解:从 Hello World 开始
c#
淡海水6 小时前
【节点】[Branch节点]原理解析与实际应用
unity·游戏引擎·shadergraph·图形·branch
唐梓航-求职中6 小时前
编程-技术-算法-leetcode-288. 单词的唯一缩写
算法·leetcode·c#
在路上看风景6 小时前
4.6 显存和缓存
unity