要应用的材质值代码块。
MaterialPropertyBlock 由 Graphics.DrawMesh 和 Renderer.SetPropertyBlock 使用。在
希望绘制具有相同材质,但属性
略有不同的多个对象时可使用它。例如,如果
要稍微更改绘制的每个网格的颜色。不支持更改渲染状态。
Unity 的地形引擎使用 MaterialPropertyBlock 绘制树;它们全都使用
相同材质,但是每棵树具有不同的颜色、缩放和风力系数。
传递给 Graphics.DrawMesh 或 Renderer.SetPropertyBlock 的代码块将被复制,因此使用它的最高效方式是
创建一个代码块并将它重复用于所有 DrawMesh 调用。使用 SetFloat、SetVector、SetColor、SetMatrix、SetTexture、SetBuffer 可添加或替换值。
另请参阅:Graphics.DrawMesh、Material。
isEmpty | 材质属性代码块是否为空?(只读) |
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 | 从属性代码块获取浮点数组。 |
GetInt | This method is deprecated. Use GetFloat or GetInteger instead. |
GetInteger | Get an integer from the property block. |
GetMatrix | 从属性代码块获取矩阵。 |
GetMatrixArray | 从属性代码块获取矩阵数组。 |
GetTexture | 从属性代码块获取纹理。 |
GetVector | 从属性代码块获取向量。 |
GetVectorArray | 从属性代码块获取向量数组。 |
HasBuffer | Checks if MaterialPropertyBlock has the ComputeBuffer property with the given name or name ID. To set the property, use SetBuffer. |
HasColor | Checks if MaterialPropertyBlock has the Color property with the given name or name ID. To set the property, use SetColor. |
HasConstantBuffer | Checks if MaterialPropertyBlock has the ConstantBuffer property with the given name or name ID. To set the property, use SetConstantBuffer. |
HasFloat | Checks if MaterialPropertyBlock has the Float property with the given name or name ID. To set the property, use SetFloat. |
HasInt | This method is deprecated. Use HasFloat or HasInteger instead. |
HasInteger | Checks if MaterialPropertyBlock has the Integer property with the given name or name ID. To set the property, use SetInteger. |
HasMatrix | Checks if MaterialPropertyBlock has the Matrix property with the given name or name ID. This also works with the Matrix Array property. To set the property, use SetMatrix. |
HasProperty | Checks if MaterialPropertyBlock has the property with the given name or name ID. To set the property, use one of the Set methods for MaterialPropertyBlock. |
HasTexture | Checks if MaterialPropertyBlock has the Texture property with the given name or name ID. To set the property, use SetTexture. |
HasVector | Checks if MaterialPropertyBlock has the Vector property with the given name or name ID. This also works with the Vector Array property. To set the property, use SetVector. |
SetBuffer | Set a buffer property. |
SetColor | 设置颜色属性。 |
SetConstantBuffer | Sets a ComputeBuffer or GraphicsBuffer as a named constant buffer for the MaterialPropertyBlock. |
SetFloat | 设置浮点属性。 |
SetFloatArray | 设置浮点数组属性。 |
SetInt | This method is deprecated. Use SetFloat or SetInteger instead. |
SetInteger | Adds a property to the block. If an integer property with the given name already exists, the old value is replaced. |
SetMatrix | 设置矩阵属性。 |
SetMatrixArray | 设置矩阵数组属性。 |
SetTexture | 设置纹理属性。 |
SetVector | 设置向量属性。 |
SetVectorArray | 设置向量数组属性。 |