Version: 2021.1

Material

class in UnityEngine

/

继承自:Object

切换到手册

描述

材质类。

此类公开材质的所有属性,供您动画化这些属性。 还可以使用它设置无法通过 Inspector 访问的自定义 着色器属性(例如矩阵)。

若要获取对象使用的材质,请使用 Renderer.material 属性。

另请参阅:MaterialsShaders

变量

color材质的主色。
doubleSidedGI获取和设置是否为此材质启用双面全局光照设置。
enableInstancing获取和设置是否为此材质启用 GPU 实例化。
globalIlluminationFlags定义材质应如何与光照贴图和光照探针交互。
mainTexture主纹理。
mainTextureOffset主纹理的偏移。
mainTextureScale主纹理的缩放。
passCount此材质中的通道数(只读)。
renderQueue此材质的渲染队列。
shader材质使用的着色器。
shaderKeywords此材质设置的附加着色器关键字。

构造函数

Material

公共函数

ComputeCRC从材质的内容计算 CRC 哈希值。
CopyPropertiesFromMaterial将属性从其他材质复制到此材质中。
DisableKeyword取消设置着色器关键字。
EnableKeyword设置此材质启用的着色器关键字。
FindPass返回通道 passName 的索引。
GetColor获取指定的颜色值。
GetColorArray获取指定的颜色数组。
GetFloat获取指定的浮点值。
GetFloatArray获取指定的浮点数组。
GetIntThis method is deprecated. Use GetFloat or GetInteger instead.
GetInteger获取指定的整数值。
GetMatrix从着色器获取指定的矩阵值。
GetMatrixArray获取指定的矩阵数组。
GetPassName返回索引 pass 处的着色器通道的名称。
GetShaderPassEnabled检查此材质上是否启用了给定的着色器通道。
GetTag获取材质着色器标记的值。
GetTexture获取指定的纹理。
GetTextureOffset获取纹理 propertyName 的位置偏移。
GetTexturePropertyNameIDs返回此材质上公开的所有纹理属性的名称 ID。
GetTexturePropertyNames返回此材质上公开的所有纹理属性的名称。
GetTextureScale获取纹理 propertyName 的位置缩放。
GetVector获取指定的向量值。
GetVectorArray获取指定的向量数组。
HasBufferChecks if the ShaderLab file assigned to the Material has a ComputeBuffer property with the given name.
HasColorChecks if the ShaderLab file assigned to the Material has a Color property with the given name.
HasConstantBufferChecks if the ShaderLab file assigned to the Material has a ConstantBuffer property with the given name.
HasFloatChecks if the ShaderLab file assigned to the Material has a Float property with the given name. This also works with the Float Array property.
HasIntThis method is deprecated. Use HasFloat or HasInteger instead.
HasIntegerChecks if the ShaderLab file assigned to the Material has an Integer property with the given name.
HasMatrixChecks if the ShaderLab file assigned to the Material has a Matrix property with the given name. This also works with the Matrix Array property.
HasPropertyChecks if the ShaderLab file assigned to the Material has a property with the given name.
HasTextureChecks if the ShaderLab file assigned to the Material has a Texture property with the given name.
HasVectorChecks if the ShaderLab file assigned to the Material has a Vector property with the given name. This also works with the Vector Array property.
IsKeywordEnabled此材质上是否启用了着色器关键字?
Lerp在两个材质之间对属性进行插值。
SetBufferSets a named buffer value.
SetColor设置指定的颜色值。
SetColorArray设置颜色数组属性。
SetConstantBufferSets a ComputeBuffer or GraphicsBuffer as a named constant buffer for the material.
SetFloat设置指定的浮点值。
SetFloatArray设置浮点数组属性。
SetIntThis method is deprecated. Use SetFloat or SetInteger instead.
SetInteger设置指定的整数值。
SetMatrix为着色器设置指定的矩阵。
SetMatrixArray设置矩阵数组属性。
SetOverrideTag对材质设置重写标记/值。
SetPass激活给定的 pass 以进行渲染。
SetShaderPassEnabled在每个材质级别上启用或禁用着色器通道。
SetTexture设置指定的纹理。
SetTextureOffset设置纹理 propertyName 的位置偏移。
SetTextureScale设置纹理 propertyName 的位置缩放。
SetVector设置指定的向量值。
SetVectorArray设置向量数组属性。

继承的成员

变量

hideFlags该对象应该隐藏、随场景一起保存还是由用户修改?
name对象的名称。

公共函数

GetInstanceIDGets the instance ID of the object.
ToString返回对象的名称。

静态函数

Destroy移除 GameObject、组件或资源。
DestroyImmediate立即销毁对象 /obj/。强烈建议您改用 Destroy。
DontDestroyOnLoad在加载新的 Scene 时,请勿销毁 Object。
FindObjectOfType返回第一个类型为 type 的已加载的激活对象。
FindObjectsOfTypeGets a list of all loaded objects of Type type.
Instantiate克隆 original 对象并返回克隆对象。

运算符

bool该对象是否存在?
operator !=比较两个对象是否引用不同的对象。
operator ==比较两个对象引用,判断它们是否引用同一个对象。