# Material

> Create a temporary Material.

## Definition

* **Type:** Constructor
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## Material(Shader)

Create a temporary Material.

```csharp
public Material(Shader shader)
```

### Parameters

**** (\[Shader]\(/engine/6000.5/script-reference/unityengine/shader)): Create a material with a given [Shader](/engine/6000.5/script-reference/unityengine/shader.md).

### Remarks

If you have a script which implements a custom special effect, you implement all the graphic setup using shaders & materials. Use this function to create a custom shader & material inside your script. After creating the material, use [Material.SetColor](/engine/6000.5/script-reference/unityengine/material/setcolor.md), [Material.SetTexture](/engine/6000.5/script-reference/unityengine/material/settexture.md), [Material.SetFloat](/engine/6000.5/script-reference/unityengine/material/setfloat.md), [Material.SetVector](/engine/6000.5/script-reference/unityengine/material/setvector.md), [Material.SetMatrix](/engine/6000.5/script-reference/unityengine/material/setmatrix.md) to populate the shader property values.

Additional Resources: [Materials](/engine/6000.5/manual/materials-and-shaders/materials.md), [Shaders](/engine/6000.5/script-reference/unityengine/shaders.md).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    // Creates a material from shader and texture references.
    Shader shader;
    Texture texture;
    Color color;

    void Start()
    {
        Renderer rend = GetComponent<Renderer> ();

        rend.material = new Material(shader);
        rend.material.mainTexture = texture;
        rend.material.color = color;
    }
}
```

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    // Creates a cube and assigns a material with a builtin Specular shader.
    void Start()
    {
        GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        Renderer rend = cube.GetComponent<Renderer> ();
        rend.material = new Material(Shader.Find("Specular"));
    }
}
```

## Material(Material)

Create a temporary Material.

```csharp
public Material(Material source)
```

### Parameters

**** (\[Material]\(/engine/6000.5/script-reference/unityengine/material)): Create a material by copying all properties from another material.

### Remarks

If you have a script which implements a custom special effect, you implement all the graphic setup using shaders & materials. Use this function to create a custom shader & material inside your script. After creating the material, use [Material.SetColor](/engine/6000.5/script-reference/unityengine/material/setcolor.md), [Material.SetTexture](/engine/6000.5/script-reference/unityengine/material/settexture.md), [Material.SetFloat](/engine/6000.5/script-reference/unityengine/material/setfloat.md), [Material.SetVector](/engine/6000.5/script-reference/unityengine/material/setvector.md), [Material.SetMatrix](/engine/6000.5/script-reference/unityengine/material/setmatrix.md) to populate the shader property values.

Additional Resources: [Materials](/engine/6000.5/manual/materials-and-shaders/materials.md), [Shaders](/engine/6000.5/script-reference/unityengine/shaders.md).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    // Creates a material from shader and texture references.
    Shader shader;
    Texture texture;
    Color color;

    void Start()
    {
        Renderer rend = GetComponent<Renderer> ();

        rend.material = new Material(shader);
        rend.material.mainTexture = texture;
        rend.material.color = color;
    }
}
```

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    // Creates a cube and assigns a material with a builtin Specular shader.
    void Start()
    {
        GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        Renderer rend = cube.GetComponent<Renderer> ();
        rend.material = new Material(Shader.Find("Specular"));
    }
}
```
