MaterialPropertyBlock

class in UnityEngine

Switch to Manual

Description

要应用的材质值代码块。

MaterialPropertyBlock 由 Graphics.DrawMeshRenderer.SetPropertyBlock 使用。在 希望绘制具有相同材质,但属性 略有不同的多个对象时可使用它。例如,如果 要稍微更改绘制的每个网格的颜色。不支持更改渲染状态。

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

The block passed to Graphics.DrawMesh or Renderer.SetPropertyBlock is copied, so the most efficient way of using it is to create one block and reuse it for all DrawMesh calls. Use SetFloat, SetVector, SetColor, SetMatrix, SetTexture, SetBuffer to add or replace values.

另请参阅:Graphics.DrawMeshMaterial

Variables

isEmpty材质属性代码块是否为空?(只读)

Public Functions

Clear清除材质属性值。
CopyProbeOcclusionArrayFrom此函数将整个源数组都复制到名为 unity_ProbesOcclusion 的 Vector4 属性数组中,用于实例化 Shadowmask 渲染。
CopySHCoefficientArraysFrom此函数将整个源数组都转换并复制到名为 unity_SHBb、unity_SHBb、unity_SHBb、unity_SHBb、unity_SHBb、unity_SHBb 和 unity_SHC 的 7 个 Vector4 属性数组中,用于实例化light probe渲染。
GetColor从属性代码块获取颜色。
GetFloat从属性代码块获取浮点数。
GetFloatArray从属性代码块获取浮点数组。
GetIntGet an int from the property block.
GetMatrix从属性代码块获取矩阵。
GetMatrixArray从属性代码块获取矩阵数组。
GetTexture从属性代码块获取纹理。
GetVector从属性代码块获取向量。
GetVectorArray从属性代码块获取向量数组。
SetBuffer设置 ComputeBuffer 属性。
SetColor设置颜色属性。
SetFloat设置浮点属性。
SetFloatArray设置浮点数组属性。
SetIntAdds a property to the block. If an int property with the given name already exists, the old value is replaced.
SetMatrix设置矩阵属性。
SetMatrixArray设置矩阵数组属性。
SetTexture设置纹理属性。
SetVector设置向量属性。
SetVectorArray设置向量数组属性。