• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Globals

    Material

    Inherits from:

    Imagine your game's 3D models as a stage, the Material class in Unity is the set designer, impacting the look and feel of the stage by determining how light interacts with the models. It influences their appearance, creating the essential visual ambiance of your game world. This class enables you to manipulate properties of materials used in rendering both 2D and 3D graphics. Whether it's to give a shiny metallic texture to a robot, a semi-transparent glaze to a ghostly apparition, or make a surface react to light in a specific way, the Material class aids in achieving these visual effects. Being a fundamental part of shader programming - the magic behind the colors, lighting effects, and textures in your game, the Material class is an indispensable tool in Unity. Unity's Material Documentation

    Properties

    color

    ClientOnly

    The 'color' property allows to set or retrieve the main color of the material. Changing this property can drastically affect the look of the rendered object. Unity's Material.color Documentation

    doubleSidedGI

    boolean
    ClientOnly

    The 'doubleSidedGI' property enables or disables the illumination of the back-faces of the Game object, impacting how light is reflected in the scene. Unity's Material.doubleSidedGI Documentation

    enableInstancing

    boolean
    ClientOnly

    The 'enableInstancing' property when set to true, instructs Unity to use GPU instancing. This can provide a performance boost when drawing many identical geometries that share the same material. Unity's Material.enableInstancing Documentation

    The 'mainTexture' property is used to apply or get the primary texture of the material. It allows to give detail to a GameObject by applying images to it. Unity's Material.mainTexture Documentation

    The 'mainTextureOffset' attribute allows to adjust the placement of the primary texture on the rendered object. It can be used to create various visual effects. Unity's Material.mainTextureOffset Documentation

    The 'mainTextureScale' property adjusts the size of the primary texture on the object, allowing for shrinking or stretching of the texture. Unity's Material.mainTextureScale Documentation

    passCount

    number
    ClientOnly
    ReadOnly

    The 'passCount' property gives the number of SubShader rendering passes in this material. Useful for fine grained control over complex shaders and rendering techniques. Unity's Material.passCount Documentation

    renderQueue

    number
    ClientOnly

    The 'renderQueue' property allows adjusting the place of the material in the renderer's queue. Manipulating this property can result in some objects rendering in front of or behind others. Unity's Material.renderQueue Documentation

    Methods

    ComputeCRC

    ClientOnly

    The 'ComputeCRC' method computes a cyclic redundancy check value for the material. This can be useful for comparing materials or for caching materials without storing them entirely. Unity's Material.ComputeCRC Documentation

    Returns

    number

    Returns the calculated CRC value.

    'CopyMatchingPropertiesFromMaterial' copies properties from another material that match with properties of the current material. This can be useful for duplicating only the relevant properties from another material. Unity's Material.CopyMatchingPropertiesFromMaterial Documentation

    Parameters

    The source material to copy matching properties from.

    Returns

    void

    The 'CopyPropertiesFromMaterial' method copies properties from specified material to current material. This is helpful when you need to create a new material with the same properties as an existing one. Unity's Material.CopyPropertiesFromMaterial Documentation

    Parameters

    The source material to copy properties from.

    Returns

    void

    Parameters

    keyword
    string

    Returns

    void

    Parameters

    keyword
    string

    Returns

    void

    FindPass

    ClientOnly

    The 'FindPass' method retrieves the index of a pass by its name. This can be helpful when dealing with complex rendering pipelines where specific passes need to be identified and modified. Unity's Material.FindPass Documentation

    Parameters

    passName
    string

    The name of the pass.

    Returns

    number

    The index of the pass, or -1 if the pass doesn't exist.

    GetColor

    ClientOnly

    The 'GetColor' method fetches the color value of a named property from a material. The retrieved color can be used in various ways such as coloring other elements or calculations affecting color data. Unity's Material.GetColor Documentation

    Parameters

    nameID
    number

    Returns

    The Color value of the specified property.

    GetColor

    ClientOnly

    The 'GetColor' method fetches the color value of a named property from a material. The retrieved color can be used in various ways such as coloring other elements or calculations affecting color data. Unity's Material.GetColor Documentation

    Parameters

    name
    string

    The name of the property to retrieve the color from.

    Returns

    The Color value of the specified property.

    GetFloat

    ClientOnly

    The 'GetFloat' method fetches the float value of a named property within a material. This method is often used when working with float properties of a shader that are needed for mathematical operations. Unity's Material.GetFloat Documentation

    Parameters

    nameID
    number

    Returns

    number

    The float value of the given property.

    GetFloat

    ClientOnly

    The 'GetFloat' method fetches the float value of a named property within a material. This method is often used when working with float properties of a shader that are needed for mathematical operations. Unity's Material.GetFloat Documentation

    Parameters

    name
    string

    The name of the float property to retrieve.

    Returns

    number

    The float value of the given property.

    Parameters

    nameID
    number

    Returns

    number[]

    Parameters

    name
    string

    Returns

    number[]

    GetInteger

    ClientOnly

    The 'GetInteger' method gets the integer value of a named property in a material. This can be useful when working with shader properties that represent quantifiable data or entries in an array. Unity's Material.GetInteger Documentation

    Parameters

    nameID
    number

    Returns

    number

    The integer value of the specified property.

    GetInteger

    ClientOnly

    The 'GetInteger' method gets the integer value of a named property in a material. This can be useful when working with shader properties that represent quantifiable data or entries in an array. Unity's Material.GetInteger Documentation

    Parameters

    name
    string

    The property name to retrieve the integer value from.

    Returns

    number

    The integer value of the specified property.

    GetMatrix

    ClientOnly

    The 'GetMatrix' method fetches the Matrix4x4 value of a named property in a material. This can be useful when manipulating transformations or other matrix operations within the shader used by the material. Unity's Material.GetMatrix Documentation

    Parameters

    nameID
    number

    Returns

    The Matrix4x4 value of the specified property.

    GetMatrix

    ClientOnly

    The 'GetMatrix' method fetches the Matrix4x4 value of a named property in a material. This can be useful when manipulating transformations or other matrix operations within the shader used by the material. Unity's Material.GetMatrix Documentation

    Parameters

    name
    string

    The name of the Matrix4x4 property to retrieve.

    Returns

    The Matrix4x4 value of the specified property.

    GetPassName

    ClientOnly

    The 'GetPassName' method fetches the name of a particular pass from a material. A pass in Unity represents a single rendering step, and knowing their names can be useful when dealing with complex rendering logic. Unity's Material.GetPassName Documentation

    Parameters

    pass
    number

    The index of the pass to fetch the name from.

    Returns

    string

    The name of the pass.

    The 'GetShaderPassEnabled' method gets the status (enabled/disabled) of a specific Shader pass on the material. This can be used to check how the material is being drawn, which is helpful when understanding complex materials or rendering techniques. Unity's Material.GetShaderPassEnabled Documentation

    Parameters

    passName
    string

    The name of the Shader pass whose status will be returned.

    Returns

    boolean

    Returns true if the Shader pass is enabled, false if it's not.

    GetTag

    ClientOnly

    The 'GetTag' method retrieves the value of a shader tag from this material, providing more control over the rendering process. If the specified tag does not exist, a fallback value can be provided. Unity's Material.GetTag Documentation

    Parameters

    tag
    string

    The name of the shader tag to retrieve.

    searchFallbacks
    boolean

    Whether to look in the shader's fallbacks if the tag isn't found.

    Returns

    string

    The value of the shader tag if it exists; otherwise, the defaultValue.

    GetTag

    ClientOnly

    The 'GetTag' method retrieves the value of a shader tag from this material, providing more control over the rendering process. If the specified tag does not exist, a fallback value can be provided. Unity's Material.GetTag Documentation

    Parameters

    tag
    string

    The name of the shader tag to retrieve.

    searchFallbacks
    boolean

    Whether to look in the shader's fallbacks if the tag isn't found.

    defaultValue
    string

    The value to return if the specified tag isn't found.

    Returns

    string

    The value of the shader tag if it exists; otherwise, the defaultValue.

    GetTexture

    ClientOnly

    'GetTexture' is a method that retrieves the texture mapped to a named property within a material. This allows you to access and potentially change the texture used by a material at runtime. Unity's Material.GetTexture Documentation

    Parameters

    nameID
    number

    Returns

    The Texture object currently in use by the material.

    GetTexture

    ClientOnly

    'GetTexture' is a method that retrieves the texture mapped to a named property within a material. This allows you to access and potentially change the texture used by a material at runtime. Unity's Material.GetTexture Documentation

    Parameters

    name
    string

    The name of the property to retrieve the texture from.

    Returns

    The Texture object currently in use by the material.

    The 'GetTextureOffset' method retrieves the current texture offset of a property. This can be used to ascertain the current texture offset applied to a material. Unity's Material.GetTextureOffset Documentation

    Parameters

    nameID
    number

    Returns

    The current texture offset of the material's property.

    The 'GetTextureOffset' method retrieves the current texture offset of a property. This can be used to ascertain the current texture offset applied to a material. Unity's Material.GetTextureOffset Documentation

    Parameters

    name
    string

    The name of the property to get the texture offset from.

    Returns

    The current texture offset of the material's property.

    GetTextureScale

    ClientOnly

    The 'GetTextureScale' method gets the current texture tiling of a property. This can be used in your project to determine the scaling factor applied to the texture of a material. Unity's Material.GetTextureScale Documentation

    Parameters

    nameID
    number

    Returns

    The current texture tiling of the material's property.

    GetTextureScale

    ClientOnly

    The 'GetTextureScale' method gets the current texture tiling of a property. This can be used in your project to determine the scaling factor applied to the texture of a material. Unity's Material.GetTextureScale Documentation

    Parameters

    name
    string

    The name of the property to get the texture scale from.

    Returns

    The current texture tiling of the material's property.

    GetVector

    ClientOnly

    The 'GetVector' method retrieves the Vector4 value of a named property in a material. This can be useful when dealing with vector properties of a shader. Unity's Material.GetVector Documentation

    Parameters

    nameID
    number

    Returns

    The Vector4 value of the specified property.

    GetVector

    ClientOnly

    The 'GetVector' method retrieves the Vector4 value of a named property in a material. This can be useful when dealing with vector properties of a shader. Unity's Material.GetVector Documentation

    Parameters

    name
    string

    The property name to retrieve the Vector4 value from.

    Returns

    The Vector4 value of the specified property.

    HasBuffer

    ClientOnly

    The 'HasBuffer' method verifies if the material has a particular buffer property. This is useful when dealing with advanced rendering techniques that involve ComputeBuffers or GraphicsBuffers. Unity's Material.HasBuffer Documentation

    Parameters

    nameID
    number

    Returns

    boolean

    Returns true if the buffer property exists; false otherwise.

    HasBuffer

    ClientOnly

    The 'HasBuffer' method verifies if the material has a particular buffer property. This is useful when dealing with advanced rendering techniques that involve ComputeBuffers or GraphicsBuffers. Unity's Material.HasBuffer Documentation

    Parameters

    name
    string

    The name of the buffer property to check.

    Returns

    boolean

    Returns true if the buffer property exists; false otherwise.

    HasColor

    ClientOnly

    The 'HasColor' method is used to check if the material has a certain color property. This is done before getting or setting a color property to avoid errors. Unity's Material.HasColor Documentation

    Parameters

    nameID
    number

    Returns

    boolean

    Returns true if the color property exists; false otherwise.

    HasColor

    ClientOnly

    The 'HasColor' method is used to check if the material has a certain color property. This is done before getting or setting a color property to avoid errors. Unity's Material.HasColor Documentation

    Parameters

    name
    string

    The name of the color property to check.

    Returns

    boolean

    Returns true if the color property exists; false otherwise.

    The 'HasConstantBuffer' method checks if the material has a specific constant buffer property. This can be important in high-end graphics where constant buffers are used to hold resources for shaders. Unity's Material.HasConstantBuffer Documentation

    Parameters

    nameID
    number

    Returns

    boolean

    Returns true if the constant buffer property exists; false otherwise.

    The 'HasConstantBuffer' method checks if the material has a specific constant buffer property. This can be important in high-end graphics where constant buffers are used to hold resources for shaders. Unity's Material.HasConstantBuffer Documentation

    Parameters

    name
    string

    The name of the constant buffer property to check.

    Returns

    boolean

    Returns true if the constant buffer property exists; false otherwise.

    HasFloat

    ClientOnly

    The 'HasFloat' method checks if the material has a specific float property. This is useful to prevent errors before attempting to access a float property. Unity's Material.HasFloat Documentation

    Parameters

    nameID
    number

    Returns

    boolean

    Returns true if the float property exists; otherwise, false.

    HasFloat

    ClientOnly

    The 'HasFloat' method checks if the material has a specific float property. This is useful to prevent errors before attempting to access a float property. Unity's Material.HasFloat Documentation

    Parameters

    name
    string

    The name of the float property to check.

    Returns

    boolean

    Returns true if the float property exists; otherwise, false.

    HasInteger

    ClientOnly

    The 'HasInteger' method checks if the material has a specific integer property. This is useful when dealing with custom shaders that may or may not have specific properties. Unity's Material.HasInteger Documentation

    Parameters

    nameID
    number

    Returns

    boolean

    Returns true if the integer property exists; otherwise, false.

    HasInteger

    ClientOnly

    The 'HasInteger' method checks if the material has a specific integer property. This is useful when dealing with custom shaders that may or may not have specific properties. Unity's Material.HasInteger Documentation

    Parameters

    name
    string

    The name for the integer property to check.

    Returns

    boolean

    Returns true if the integer property exists; otherwise, false.

    HasMatrix

    ClientOnly

    The 'HasMatrix' method checks if the material has a specific matrix property. It's useful in preventing errors when trying to access a matrix property. Unity's Material.HasMatrix Documentation

    Parameters

    nameID
    number

    Returns

    boolean

    Returns true if the matrix property exists; otherwise, false.

    HasMatrix

    ClientOnly

    The 'HasMatrix' method checks if the material has a specific matrix property. It's useful in preventing errors when trying to access a matrix property. Unity's Material.HasMatrix Documentation

    Parameters

    name
    string

    The name of the matrix property to check.

    Returns

    boolean

    Returns true if the matrix property exists; otherwise, false.

    HasProperty

    ClientOnly

    The 'HasProperty' method checks whether the material has a property with a given name. This can be useful to prevent errors before trying to set or get a property. Unity's Material.HasProperty Documentation

    Parameters

    nameID
    number

    The identifier for the property you are checking for.

    Returns

    boolean

    Returns true if the property exists; otherwise, false.

    HasProperty

    ClientOnly

    The 'HasProperty' method checks whether the material has a property with a given name. This can be useful to prevent errors before trying to set or get a property. Unity's Material.HasProperty Documentation

    Parameters

    name
    string

    Returns

    boolean

    Returns true if the property exists; otherwise, false.

    HasTexture

    ClientOnly

    'HasTexture' is a method that checks if the material has a specific texture property. This is handy to avoid errors when trying to access a texture property. Unity's Material.HasTexture Documentation

    Parameters

    nameID
    number

    Returns

    boolean

    Returns true if the texture property exists; otherwise, false.

    HasTexture

    ClientOnly

    'HasTexture' is a method that checks if the material has a specific texture property. This is handy to avoid errors when trying to access a texture property. Unity's Material.HasTexture Documentation

    Parameters

    name
    string

    The name of the texture property to check.

    Returns

    boolean

    Returns true if the texture property exists; otherwise, false.

    HasVector

    ClientOnly

    The 'HasVector' method checks if a specific vector property exists in the material. This can help in preventing errors when trying to access this property. Unity's Material.HasVector Documentation

    Parameters

    nameID
    number

    Returns

    boolean

    Returns true if the vector property exists; otherwise, false.

    HasVector

    ClientOnly

    The 'HasVector' method checks if a specific vector property exists in the material. This can help in preventing errors when trying to access this property. Unity's Material.HasVector Documentation

    Parameters

    name
    string

    The name of the vector property to check.

    Returns

    boolean

    Returns true if the vector property exists; otherwise, false.

    The 'IsKeywordEnabled' method checks if a specific shader keyword is enabled for this material. This can be used to verify the state of a feature of a multi-function shader. Unity's Material.IsKeywordEnabled Documentation

    Parameters

    keyword
    string

    The keyword to check.

    Returns

    boolean

    Returns true if the keyword is enabled, false otherwise.

    Lerp

    ClientOnly

    The 'Lerp' method linearly interpolates between two Materials based on t parameter and applies the result to this Material. It's useful to blend between different materials dynamically, creating a transition effect. Unity's Material.Lerp Documentation

    Parameters

    The start Material for the Lerp operation.

    The end Material for the Lerp operation.

    t
    number

    The Lerp weighting factor.

    Returns

    void

    SetColor

    ClientOnly

    The 'SetColor' method sets a color property in the material. This can be used to change the color of the material at runtime, allowing for dynamic visual effects. Unity's Material.SetColor Documentation

    Parameters

    nameID
    number
    value

    The color value to set the property to.

    Returns

    void

    SetColor

    ClientOnly

    The 'SetColor' method sets a color property in the material. This can be used to change the color of the material at runtime, allowing for dynamic visual effects. Unity's Material.SetColor Documentation

    Parameters

    name
    string

    The name for the color property to set.

    value

    The color value to set the property to.

    Returns

    void

    Parameters

    nameID
    number
    values

    Returns

    void

    Parameters

    name
    string
    values

    Returns

    void

    SetFloat

    ClientOnly

    'SetFloat' is a method used to set a float property in the material. It is typically used to interact with float properties defined in the shader used by the material. Unity's Material.SetFloat Documentation

    Parameters

    nameID
    number
    value
    number

    The float value to set the property to.

    Returns

    void

    SetFloat

    ClientOnly

    'SetFloat' is a method used to set a float property in the material. It is typically used to interact with float properties defined in the shader used by the material. Unity's Material.SetFloat Documentation

    Parameters

    name
    string

    The name of the property to set.

    value
    number

    The float value to set the property to.

    Returns

    void

    Parameters

    nameID
    number
    values
    number[]

    Returns

    void

    Parameters

    name
    string
    values
    number[]

    Returns

    void

    SetInteger

    ClientOnly

    The 'SetInteger' method is used to set an integer property in the material. It can be used to interact with integer properties defined in the shader used by the material. Unity's Material.SetInteger Documentation

    Parameters

    nameID
    number
    value
    number

    The integer value to set the property to.

    Returns

    void

    SetInteger

    ClientOnly

    The 'SetInteger' method is used to set an integer property in the material. It can be used to interact with integer properties defined in the shader used by the material. Unity's Material.SetInteger Documentation

    Parameters

    name
    string

    The name of the property to set.

    value
    number

    The integer value to set the property to.

    Returns

    void

    SetMatrix

    ClientOnly

    'SetMatrix' is a method that sets a Matrix4x4 property in the material. This can be used to affect transformations or other matrix operations within the shader used by the material. Unity's Material.SetMatrix Documentation

    Parameters

    nameID
    number

    The Matrix4x4 value to set the property to.

    Returns

    void

    SetMatrix

    ClientOnly

    'SetMatrix' is a method that sets a Matrix4x4 property in the material. This can be used to affect transformations or other matrix operations within the shader used by the material. Unity's Material.SetMatrix Documentation

    Parameters

    name
    string

    The name of the Matrix4x4 property to set.

    The Matrix4x4 value to set the property to.

    Returns

    void

    Parameters

    nameID
    number

    Returns

    void

    Parameters

    name
    string

    Returns

    void

    SetOverrideTag

    ClientOnly

    The 'SetOverrideTag' method overrides or sets a shader tag for this material. Shader tags in Unity are used to determine how to render an object, and overriding them can help achieve unique rendering effects for particular materials. Unity's Material.SetOverrideTag Documentation

    Parameters

    tag
    string

    The tag to be overridden in this material.

    val
    string

    The value to set for the overridden tag.

    Returns

    void

    SetPass

    ClientOnly

    'SetPass' activates a given Shader Pass for rendering current object. It's used to set a particular pass in the material’s shader to the rendering hardware. Unity's Material.SetPass Documentation

    Parameters

    pass
    number

    The index of the pass to set.

    Returns

    boolean

    If the shader or pass is not valid, this function will return false; otherwise, it returns true.

    The 'SetShaderPassEnabled' method enables or disables a specific Shader pass on the material. This offers more control over the rendering process, which can be useful for complex materials or advanced rendering techniques. Unity's Material.SetShaderPassEnabled Documentation

    Parameters

    passName
    string

    The name of the Shader pass to enable or disable.

    enabled
    boolean

    Whether the Shader pass should be enabled.

    Returns

    void

    SetTexture

    ClientOnly

    The 'SetTexture' method assigns a texture to a named property within a shader. It can be used to dynamically change the textures used by a material at runtime. Unity's Material.SetTexture Documentation

    Parameters

    nameID
    number
    value

    The Texture object to use.

    Returns

    void

    SetTexture

    ClientOnly

    The 'SetTexture' method assigns a texture to a named property within a shader. It can be used to dynamically change the textures used by a material at runtime. Unity's Material.SetTexture Documentation

    Parameters

    name
    string

    The name of the texture property to set.

    value

    The Texture object to use.

    Returns

    void

    The 'SetTextureOffset' method adjusts the texture coordinates of a material, effectively shifting the texture. This can be useful for creating effects like scrolling textures. Unity's Material.SetTextureOffset Documentation

    Parameters

    nameID
    number
    value

    The amount of texture offset to apply.

    Returns

    void

    The 'SetTextureOffset' method adjusts the texture coordinates of a material, effectively shifting the texture. This can be useful for creating effects like scrolling textures. Unity's Material.SetTextureOffset Documentation

    Parameters

    name
    string

    The property name to which Texture offset will be applied.

    value

    The amount of texture offset to apply.

    Returns

    void

    SetTextureScale

    ClientOnly

    'SetTextureScale' adjusts the scaling of the texture coordinates of a material, effectively altering the tiling of the texture. This feature can be used for various visual effects, like magnifying or shrinking the appearance of a texture. Unity's Material.SetTextureScale Documentation

    Parameters

    nameID
    number
    value

    The amount of texture scaling to apply.

    Returns

    void

    SetTextureScale

    ClientOnly

    'SetTextureScale' adjusts the scaling of the texture coordinates of a material, effectively altering the tiling of the texture. This feature can be used for various visual effects, like magnifying or shrinking the appearance of a texture. Unity's Material.SetTextureScale Documentation

    Parameters

    name
    string

    The property name to which Texture scaling will be applied.

    value

    The amount of texture scaling to apply.

    Returns

    void

    SetVector

    ClientOnly

    The 'SetVector' method sets a Vector4 property in the material. This can be very useful when applying transformations or other operations that can be done through vector properties of a shader. Unity's Material.SetVector Documentation

    Parameters

    nameID
    number
    value

    The Vector4 value to set the property to.

    Returns

    void

    SetVector

    ClientOnly

    The 'SetVector' method sets a Vector4 property in the material. This can be very useful when applying transformations or other operations that can be done through vector properties of a shader. Unity's Material.SetVector Documentation

    Parameters

    name
    string

    The name of the Vector4 property to set.

    value

    The Vector4 value to set the property to.

    Returns

    void

    Parameters

    nameID
    number
    values

    Returns

    void

    Parameters

    name
    string
    values

    Returns

    void

    Updated 18 days ago

    PocketWorlds Icon

    © 2025 Pocket Worlds. All rights reserved.