# Texture2D

> Create a new empty texture.

## Definition

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

## Texture2D(int, int, TextureFormat, int, bool)

Create a new empty texture.

```csharp
public Texture2D(int width, int height, TextureFormat textureFormat, int mipCount, bool linear)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[TextureFormat]\(/engine/6000.0/script-reference/unityengine/textureformat)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)):&#x20;

### Remarks

The texture will be width by height size, with a given format, with mipmaps or without, and in either the linear color space or the sRGB color space. width and height must be greater than 0.

Usually you will want to set the colors of the texture after creating it, using [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md) and [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

Additional Resources: [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md), [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

## Texture2D(int, int, TextureFormat, int, bool, bool)

Create a new empty texture.

```csharp
public Texture2D(int width, int height, TextureFormat textureFormat, int mipCount, bool linear, bool createUninitialized)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[TextureFormat]\(/engine/6000.0/script-reference/unityengine/textureformat)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)):&#x20;

### Remarks

The texture will be width by height size, with a given format, with mipmaps or without, and in either the linear color space or the sRGB color space. width and height must be greater than 0.

Enable createUninitialized to make the texture reference uninitialized data (both on the CPU and GPU). When overriding all texels, this can lead to improved performance and reduced memory usage during construction. Note that sampling an uninitialized texture gives unpredictable values.

Usually you will want to set the colors of the texture after creating it, using [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md) and [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

Additional Resources: [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md), [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

## Texture2D(int, int, TextureFormat, int, bool, bool, MipmapLimitDescriptor)

Create a new empty texture.

```csharp
public Texture2D(int width, int height, TextureFormat textureFormat, int mipCount, bool linear, bool createUninitialized, MipmapLimitDescriptor mipmapLimitDescriptor)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[TextureFormat]\(/engine/6000.0/script-reference/unityengine/textureformat)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): **** (\[MipmapLimitDescriptor]\(/engine/6000.0/script-reference/unityengine/mipmaplimitdescriptor)):&#x20;

### Remarks

The texture will be width by height size, with a given format, with mipmaps or without, and in either the linear color space or the sRGB color space. width and height must be greater than 0.

Enable createUninitialized to make the texture reference uninitialized data (both on the CPU and GPU). When overriding all texels, this can lead to improved performance and reduced memory usage during construction. Note that sampling an uninitialized texture gives unpredictable values.

Use a [MipmapLimitDescriptor](/engine/6000.0/script-reference/unityengine/mipmaplimitdescriptor.md) to make the texture use the global mipmap limit from the current Quality Settings, or the mipmap limit of a [TextureMipmapLimitGroup](/engine/6000.0/script-reference/unityengine/texturemipmaplimitgroups.md). Note that a readable CPU copy is required for the texture to reupload when quality settings change. If the texture is made nonreadable (see [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md)), the uploaded resolution will no longer adapt to the active quality level.

Usually you will want to set the colors of the texture after creating it, using [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md) and [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

Additional Resources: [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md), [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

## Texture2D(int, int, TextureFormat, int, bool, bool, bool, string)

Create a new empty texture.

> **Warning:**
>
> **Deprecated.** Please provide mipmap limit information using a MipmapLimitDescriptor argument

```csharp
public Texture2D(int width, int height, TextureFormat textureFormat, int mipCount, bool linear, bool createUninitialized, bool ignoreMipmapLimit, string mipmapLimitGroupName)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[TextureFormat]\(/engine/6000.0/script-reference/unityengine/textureformat)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): **** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)):&#x20;

### Remarks

The texture will be width by height size, with an RGBA32 [TextureFormat](/engine/6000.0/script-reference/unityengine/textureformat.md), with mipmaps and in sRGB color space.

Usually you will want to set the colors of the texture after creating it, using [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md) and [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

```csharp
// Create a new texture and assign it to the renderer's material
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        Texture2D texture = new Texture2D(128, 128);
        Renderer renderer = GetComponent<Renderer>();
        renderer.material.mainTexture = texture;
    }
}
```

Additional Resources: [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md), [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

## Texture2D(int, int, TextureFormat, bool, bool)

Create a new empty texture.

```csharp
public Texture2D(int width, int height, TextureFormat textureFormat, bool mipChain, bool linear)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[TextureFormat]\(/engine/6000.0/script-reference/unityengine/textureformat)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)):&#x20;

### Remarks

The texture will be width by height size, with a given format, with mipmaps or without, and in either the linear color space or the sRGB color space. width and height must be greater than 0.

Usually you will want to set the colors of the texture after creating it, using [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md) and [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

Additional Resources: [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md), [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

## Texture2D(int, int, TextureFormat, bool, bool, bool)

Create a new empty texture.

```csharp
public Texture2D(int width, int height, TextureFormat textureFormat, bool mipChain, bool linear, bool createUninitialized)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[TextureFormat]\(/engine/6000.0/script-reference/unityengine/textureformat)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)):&#x20;

### Remarks

The texture will be width by height size, with a given format, with mipmaps or without, and in either the linear color space or the sRGB color space. width and height must be greater than 0.

Enable createUninitialized to make the texture reference uninitialized data (both on the CPU and GPU). When overriding all texels, this can lead to improved performance and reduced memory usage during construction. Note that sampling an uninitialized texture gives unpredictable values.

Usually you will want to set the colors of the texture after creating it, using [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md) and [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

Additional Resources: [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md), [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

## Texture2D(int, int, TextureFormat, bool)

Create a new empty texture.

```csharp
public Texture2D(int width, int height, TextureFormat textureFormat, bool mipChain)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[TextureFormat]\(/engine/6000.0/script-reference/unityengine/textureformat)): **** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)):&#x20;

### Remarks

The texture will be width by height size, with a given format, with mipmaps or without. width and height must be greater than 0.

Usually you will want to set the colors of the texture after creating it, using [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md) and [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

Additional Resources: [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md), [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

## Texture2D(int, int)

Create a new empty texture.

```csharp
public Texture2D(int width, int height)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)):&#x20;

### Remarks

The texture will be width by height size, with an RGBA32 [TextureFormat](/engine/6000.0/script-reference/unityengine/textureformat.md), with mipmaps and in sRGB color space.

Usually you will want to set the colors of the texture after creating it, using [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md) and [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.

```csharp
// Create a new texture and assign it to the renderer's material
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        Texture2D texture = new Texture2D(128, 128);
        Renderer renderer = GetComponent<Renderer>();
        renderer.material.mainTexture = texture;
    }
}
```

Additional Resources: [Texture2D.SetPixel](/engine/6000.0/script-reference/unityengine/texture2d/setpixel.md), [Texture2D.SetPixels](/engine/6000.0/script-reference/unityengine/texture2d/setpixels.md), [Texture2D.Apply](/engine/6000.0/script-reference/unityengine/texture2d/apply.md) functions.
