MaterialPropertyBlock 材质属性块

A block of material values to apply.

应用的一块材质值。

MaterialPropertyBlock is used by Graphics.DrawMesh. Use it in situations where you want to draw multiple objects with the same material, but slightly different properties. For example, if you want to slightly change the color of each mesh drawn.

MateriaIPropcrtyBlock被Graphics.DrawMesh使用。在你想用相同的材质(但有稍微有些不同的属性)绘制多个物体时,使用这个。例如,如果你想稍微改变每个网络的颜色时。

Unity's terrain engine uses MaterialPropertyBlock to draw trees; all of them use the same material, but each tree has different color, scale & wind factor.

Unity的地形引擎使用MaterialPropertyBlock来绘制树;他们全部使用相同的材质,但是每棵树具有不同的颜色、缩放和受风力。

For performance reasons, the property block can contain only a limited number of property values. Two 4x4 matrices, 7 vectors/colors or 14 floats can be stored in the block. Storage space for the values is shared, so storing one matrix leaves twice less space to store vectors and floats.

出于性能原因,属性块只能包含属性值的有限数量。两个4x4矩阵,7个向量颜色或14个浮点数可以存储在这个块中,存储空间的值被共享,所以存储一个矩阵留下两倍少的空间来存储向量和浮点数。

Graphics.DrawMesh copies the passed property block, so the most efficient way of using it is to create one block and reuse it for all DrawMesh calls. Use Clear to clear block's values, and AddFloat, AddVector, AddColor, AddMatrix to add values.

Graphics.DrawMesh 拷贝传递的属性块,因此最有效的方法是使用它来创建一个块并为所有DrawMesh调用再使用它。使用Clear来清除块的值,AddFloat,AddVector,AddColot,AddMatrix来添加值。

参见: Graphics.DrawMesh, Material.

Functions函数

最后修改:2011年3月1日 Tuesday 22:34

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。