材质类。
此类公开材质的所有属性,供您动画化这些属性。
还可以使用它设置无法通过 Inspector 访问的自定义
着色器属性(例如矩阵)。
若要获取对象使用的材质,请使用 Renderer.material 属性。
另请参阅:Materials、Shaders。
color | 材质的主色。 |
doubleSidedGI | 获取和设置是否为此材质启用双面全局光照设置。 |
enabledKeywords | An array containing the local shader keywords that are currently enabled for this material. |
enableInstancing | 获取和设置是否为此材质启用 GPU 实例化。 |
globalIlluminationFlags | 定义材质应如何与光照贴图和光照探针交互。 |
isVariant | Returns true if this material is a material variant. |
mainTexture | 主纹理。 |
mainTextureOffset | 主纹理的偏移。 |
mainTextureScale | 主纹理的缩放。 |
parent | Parent of this material. |
passCount | 此材质中的通道数(只读)。 |
renderQueue | 此材质的渲染队列。 |
shader | 材质使用的着色器。 |
shaderKeywords | An array containing names of the local shader keywords that are currently enabled for this material. |
Material |
ApplyPropertyOverride | Applies an override associated with a Material Variant to a target. |
ComputeCRC | 从材质的内容计算 CRC 哈希值。 |
CopyPropertiesFromMaterial | 将属性从其他材质复制到此材质中。 |
DisableKeyword | Disables a local shader keyword for this material. |
EnableKeyword | Enables a local shader keyword for this material. |
FindPass | 返回通道 passName 的索引。 |
GetColor | 获取指定的颜色值。 |
GetColorArray | 获取指定的颜色数组。 |
GetFloat | 获取指定的浮点值。 |
GetFloatArray | 获取指定的浮点数组。 |
GetInt | This 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 | 获取指定的向量数组。 |
HasBuffer | Checks if the ShaderLab file assigned to the Material has a ComputeBuffer property with the given name. |
HasColor | Checks if the ShaderLab file assigned to the Material has a Color property with the given name. |
HasConstantBuffer | Checks if the ShaderLab file assigned to the Material has a ConstantBuffer property with the given name. |
HasFloat | Checks if the ShaderLab file assigned to the Material has a Float property with the given name. This also works with the Float Array property. |
HasInt | This method is deprecated. Use HasFloat or HasInteger instead. |
HasInteger | Checks if the ShaderLab file assigned to the Material has an Integer property with the given name. |
HasMatrix | Checks if the ShaderLab file assigned to the Material has a Matrix property with the given name. This also works with the Matrix Array property. |
HasProperty | Checks if the ShaderLab file assigned to the Material has a property with the given name. |
HasTexture | Checks if the ShaderLab file assigned to the Material has a Texture property with the given name. |
HasVector | Checks if the ShaderLab file assigned to the Material has a Vector property with the given name. This also works with the Vector Array property. |
IsChildOf | Returns True if the given material is an ancestor of this Material. |
IsKeywordEnabled | Checks whether a local shader keyword is enabled for this material. |
IsPropertyLocked | Checks whether a property is locked by this material. |
IsPropertyLockedByAncestor | Checks whether a property is locked by any of ancestor of this material. |
IsPropertyOverriden | Checks whether a property is overriden by this material. |
Lerp | 在两个材质之间对属性进行插值。 |
RevertAllPropertyOverrides | Removes all property overrides on this material. |
RevertPropertyOverride | Removes the override on a property. |
SetBuffer | Sets a named buffer value. |
SetColor | Sets a color value. |
SetColorArray | 设置颜色数组属性。 |
SetConstantBuffer | Sets a ComputeBuffer or GraphicsBuffer as a named constant buffer for the material. |
SetFloat | 设置指定的浮点值。 |
SetFloatArray | 设置浮点数组属性。 |
SetInt | This method is deprecated. Use SetFloat or SetInteger instead. |
SetInteger | 设置指定的整数值。 |
SetKeyword | Sets the state of a local shader keyword for this material. |
SetMatrix | 为着色器设置指定的矩阵。 |
SetMatrixArray | 设置矩阵数组属性。 |
SetOverrideTag | 对材质设置重写标记/值。 |
SetPass | 激活给定的 pass 以进行渲染。 |
SetPropertyLock | Sets the lock state of a property for this material. |
SetShaderPassEnabled | 在每个材质级别上启用或禁用着色器通道。 |
SetTexture | 设置指定的纹理。 |
SetTextureOffset | 设置纹理 propertyName 的位置偏移。 |
SetTextureScale | 设置纹理 propertyName 的位置缩放。 |
SetVector | 设置指定的向量值。 |
SetVectorArray | 设置向量数组属性。 |
GetInstanceID | Gets the instance ID of the object. |
ToString | 返回对象的名称。 |
Destroy | 移除 GameObject、组件或资源。 |
DestroyImmediate | 立即销毁对象 /obj/。强烈建议您改用 Destroy。 |
DontDestroyOnLoad | 在加载新的 Scene 时,请勿销毁 Object。 |
FindObjectOfType | 返回第一个类型为 type 的已加载的激活对象。 |
FindObjectsOfType | Gets a list of all loaded objects of Type type. |
Instantiate | 克隆 original 对象并返回克隆对象。 |
bool | 该对象是否存在? |
operator != | 比较两个对象是否引用不同的对象。 |
operator == | 比较两个对象引用,判断它们是否引用同一个对象。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.