Version: 2020.1
LanguageEnglish
  • C#

Material

class in UnityEngine

/

Inherits from:Object

/

Implemented in:UnityEngine.CoreModule

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Description

The material class.

This class exposes all properties from a material, allowing you to animate them. You can also use it to set custom shader properties that can't be accessed through the inspector (e.g. matrices).

In order to get the material used by an object, use the Renderer.material property.

See Also: Materials, Shaders.

Properties

colorThe main color of the Material.
doubleSidedGIGets and sets whether the Double Sided Global Illumination setting is enabled for this material.
enableInstancingGets and sets whether GPU instancing is enabled for this material.
globalIlluminationFlagsDefines how the material should interact with lightmaps and lightprobes.
mainTextureThe main texture.
mainTextureOffsetThe offset of the main texture.
mainTextureScaleThe scale of the main texture.
passCountHow many passes are in this material (Read Only).
renderQueueRender queue of this material.
shaderThe shader used by the material.
shaderKeywordsAdditional shader keywords set by this material.

Constructors

Material

Public Methods

ComputeCRCComputes a CRC hash value from the content of the material.
CopyPropertiesFromMaterialCopy properties from other material into this material.
DisableKeywordUnset a shader keyword.
EnableKeywordSets a shader keyword that is enabled by this material.
FindPassReturns the index of the pass passName.
GetColorGet a named color value.
GetColorArrayGet a named color array.
GetFloatGet a named float value.
GetFloatArrayGet a named float array.
GetIntGet a named integer value.
GetMatrixGet a named matrix value from the shader.
GetMatrixArrayGet a named matrix array.
GetPassNameReturns the name of the shader pass at index pass.
GetShaderPassEnabledChecks whether a given Shader pass is enabled on this Material.
GetTagGet the value of material's shader tag.
GetTextureGet a named texture.
GetTextureOffsetGets the placement offset of texture propertyName.
GetTexturePropertyNameIDsReturn the name IDs of all texture properties exposed on this material.
GetTexturePropertyNamesReturns the names of all texture properties exposed on this material.
GetTextureScaleGets the placement scale of texture propertyName.
GetVectorGet a named vector value.
GetVectorArrayGet a named vector array.
HasPropertyChecks if material's shader has a property of a given name.
IsKeywordEnabledIs the shader keyword enabled on this material?
LerpInterpolate properties between two materials.
SetBufferSets a named buffer value.
SetColorSets a named color value.
SetColorArraySets a color array property.
SetConstantBufferSets a ComputeBuffer or GraphicsBuffer as a named constant buffer for the material.
SetFloatSets a named float value.
SetFloatArraySets a float array property.
SetIntSets a named integer value.
SetMatrixSets a named matrix for the shader.
SetMatrixArraySets a matrix array property.
SetOverrideTagSets an override tag/value on the material.
SetPassActivate the given pass for rendering.
SetShaderPassEnabledEnables or disables a Shader pass on a per-Material level.
SetTextureSets a named texture.
SetTextureOffsetSets the placement offset of texture propertyName.
SetTextureScaleSets the placement scale of texture propertyName.
SetVectorSets a named vector value.
SetVectorArraySets a vector array property.

Inherited Members

Properties

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public Methods

GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the object.

Static Methods

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答