MaterialPropertyBlock

class in UnityEngine

Cambiar al Manual

Descripción

A block of material values to apply.

MaterialPropertyBlock is used by Graphics.DrawMesh and Renderer.SetPropertyBlock. 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. Changing the render state is not supported.

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.

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.

See Also: Graphics.DrawMesh, Material.

Variables

isEmptyIs the material property block empty? (Read Only)

Funciones Públicas

ClearClear material property values.
CopyProbeOcclusionArrayFromThis function copies the entire source array into a Vector4 property array named unity_ProbesOcclusion for use with instanced Shadowmask rendering.
CopySHCoefficientArraysFromThis function converts and copies the entire source array into 7 Vector4 property arrays named unity_SHAr, unity_SHAg, unity_SHAb, unity_SHBr, unity_SHBg, unity_SHBb and unity_SHC for use with instanced light probe rendering.
GetColorGet a color from the property block.
GetFloatGet a float from the property block.
GetFloatArrayGet a float array from the property block.
GetIntGet an int from the property block.
GetMatrixGet a matrix from the property block.
GetMatrixArrayGet a matrix array from the property block.
GetTextureGet a texture from the property block.
GetVectorGet a vector from the property block.
GetVectorArrayGet a vector array from the property block.
SetBufferSet a buffer property.
SetColorSet a color property.
SetConstantBufferSets a ComputeBuffer or GraphicsBuffer as a named constant buffer for the MaterialPropertyBlock.
SetFloatSet a float property.
SetFloatArrayEstablece una propiedad de arreglo float.
SetIntAdds a property to the block. If an int property with the given name already exists, the old value is replaced.
SetMatrixSet a matrix property.
SetMatrixArrayEstablece una propiedad arreglo de matriz.
SetTextureSet a texture property.
SetVectorSet a vector property.
SetVectorArrayEstablece una propiedad de un arreglo de vector.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961