unity, access standard shared emission by script

unity 5.1.1f1 personal

用下面方法在脚本中设置standard shader的emssion:

gameObject.GetComponent<MeshRenderer> ().material.SetColor("_EmissionColor",color);

一个很奇怪的现象是:如果material的inspector中此standard shader的emission值为(0,0,0),则上面语句不起作用。

所以为了使上面语句能生效,需要把inspector中emission的值设置为非(0,0,0)。

参考:http://hutonggames.com/playmakerforum/index.php?topic=9833.0

原文地址:https://www.cnblogs.com/wantnon/p/4927595.html