Version: 2023.1

Material

class in UnityEngine

/

继承自:Object

切换到手册

描述

材质类。

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

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

另请参阅:MaterialsShaders

变量

color材质的主色。
doubleSidedGI获取和设置是否为此材质启用双面全局光照设置。
enabledKeywordsAn array containing the local shader keywords that are currently enabled for this material.
enableInstancing获取和设置是否为此材质启用 GPU 实例化。
globalIlluminationFlags定义材质应如何与光照贴图和光照探针交互。
isVariantReturns true if this material is a material variant.
mainTexture主纹理。
mainTextureOffset主纹理的偏移。
mainTextureScale主纹理的缩放。
parentParent of this material.
passCount此材质中的通道数(只读)。
renderQueue此材质的渲染队列。
shader材质使用的着色器。
shaderKeywordsAn array containing names of the local shader keywords that are currently enabled for this material.

构造函数

Material

公共函数

ApplyPropertyOverrideApplies an override associated with a Material Variant to a target.
ComputeCRC从材质的内容计算 CRC 哈希值。
CopyMatchingPropertiesFromMaterialCopies properties, keyword states and settings from mat to this material, but only if they exist in both materials.
CopyPropertiesFromMaterial将属性从其他材质复制到此材质中。
DisableKeywordDisables a local shader keyword for this material.
EnableKeywordEnables a local shader keyword for this material.
FindPass返回通道 passName 的索引。
GetBufferGet a named Graphics Buffer value.
GetColor获取指定的颜色值。
GetColorArray获取指定的颜色数组。
GetConstantBufferGet a named Constant Buffer value.
GetFloat获取指定的浮点值。
GetFloatArray获取指定的浮点数组。
GetIntThis method is deprecated. Use GetFloat or GetInteger instead.
GetInteger获取指定的整数值。
GetMatrix从着色器获取指定的矩阵值。
GetMatrixArray获取指定的矩阵数组。
GetPassName返回索引 pass 处的着色器通道的名称。
GetPropertyNamesRetrieves a list of the named properties in the material that match the input property type.
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.
IsChildOfReturns True if the given material is an ancestor of this Material.
IsKeywordEnabledChecks whether a local shader keyword is enabled for this material.
IsPropertyLockedChecks whether a property is locked by this material.
IsPropertyLockedByAncestorChecks whether a property is locked by any of ancestor of this material.
IsPropertyOverridenChecks whether a property is overriden by this material.
Lerp在两个材质之间对属性进行插值。
RevertAllPropertyOverridesRemoves all property overrides on this material.
RevertPropertyOverrideRemoves the override on a property.
SetBufferSets a named buffer value.
SetColorSets a color value.
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设置指定的整数值。
SetKeywordSets the state of a local shader keyword for this material.
SetMatrix为着色器设置指定的矩阵。
SetMatrixArray设置矩阵数组属性。
SetOverrideTag对材质设置重写标记/值。
SetPass激活给定的 pass 以进行渲染。
SetPropertyLockSets the lock state of a property for this material.
SetShaderPassEnabled在每个材质级别上启用或禁用着色器通道。
SetTexture设置指定的纹理。
SetTextureOffsetSets the placement offset of a given texture. The name parameter is defined in the shader. This method creates a new Material instance.
SetTextureScale设置纹理 propertyName 的位置缩放。
SetVector设置指定的向量值。
SetVectorArray设置向量数组属性。

继承的成员

变量

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

公共函数

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

静态函数

Destroy移除 GameObject、组件或资源。
DestroyImmediate立即销毁对象 /obj/。强烈建议您改用 Destroy。
DontDestroyOnLoad在加载新的 Scene 时,请勿销毁 Object。
FindAnyObjectByTypeRetrieves any active loaded object of Type type.
FindFirstObjectByTypeRetrieves the first active loaded object of Type type.
FindObjectsByTypeRetrieves a list of all loaded objects of Type type.
Instantiate克隆 original 对象并返回克隆对象。

运算符

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