【发布时间】:2020-09-08 08:20:32
【问题描述】:
我画了很多不同颜色的盒子。为此,我正在使用 MaterialPropertyBlocks
public override void DrawPlot()
{
for (int posIdx = 0; posIdx < data.Length; posIdx++)
{
plotModelInstances[posIdx] = GameObject.Instantiate(plotModel, ...);
_propBlock = new MaterialPropertyBlock();
_renderer = plotModelInstances[posIdx].GetComponent<Renderer>();
_renderer.GetPropertyBlock(_propBlock);
_propBlock.SetColor("Color", MiscUtils.GetColor(data[posIdx].Value / maxValue, StaticValues.jet));
_renderer.SetPropertyBlock(_propBlock);
}
}
此函数是(非单一行为)类的一部分。 问题是,如果我运行程序,所有块都是白色的。 那是因为我在 MonoBehaviour 脚本之外使用 MaterialPropertyBlocks 吗?
【问题讨论】: