# Reinitialize

> Reinitializes a Texture2D, making it possible for you to replace width, height, textureformat, and graphicsformat data for that texture.

## Definition

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

## Reinitialize(int, int)

Reinitializes a Texture2D, making it possible for you to replace `width`, `height`, `textureformat`, and `graphicsformat` data for that texture.

```csharp
public bool Reinitialize(int width, int height)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new width of the texture.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new height of the texture.

### Returns

| Type                                                          | Description                                   |
| ------------------------------------------------------------- | --------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the reinitialization was a success. |

### Remarks

This action also clears the pixel data associated with the texture from the CPU and GPU.

This function is very similar to the [Texture](/engine/6000.6/script-reference/unityengine/texture.md) constructor, except it works on a Texture object that already exists rather than creating a new one.

It is not possible to reinitialize **Crunched** textures, so if you pass a **Crunched** texture to this method, it returns `false`.  See [texture formats](/engine/6000.6/manual/materials-and-shaders/textures/textures-getting-started/texture-compression-formats.md) for more information about compressed and crunched textures.

Call [Texture2D.Apply](/engine/6000.6/script-reference/unityengine/texture2d/apply.md) to  upload the changed pixels to the graphics card.

[Texture.isReadable](/engine/6000.6/script-reference/unityengine/texture/isreadable.md) must be `true`.

`Texture2D.Reinitialize` does not automatically update the [special texture properties](/engine/6000.6/manual/materials-and-shaders/shaders/writing-custom/shader-writing/writing-shader-change-properties/sl-properties-in-programs.md) \{TextureName}`_TexelSize` and \{TextureName}`_HDR`, which Unity sets automatically on shaders and materials that use the texture. After using `Texture2D.Reinitialize`, you should update \{TextureName}`_TexelSize` and \{TextureName}`_HDR` on your material or shader if you need them.

## Reinitialize(int, int, TextureFormat, bool)

Reinitializes a Texture2D, making it possible for you to replace `width`, `height`, `textureformat`, and `graphicsformat` data for that texture.

```csharp
public bool Reinitialize(int width, int height, TextureFormat format, bool hasMipMap)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new width of the texture.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new height of the texture.**** (\[TextureFormat]\(/engine/6000.6/script-reference/unityengine/textureformat)): The new format of the texture.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether the texture reserves memory for a full mipmap chain.

### Returns

| Type                                                          | Description                                   |
| ------------------------------------------------------------- | --------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the reinitialization was a success. |

### Remarks

This action also clears the pixel data associated with the texture from the CPU and GPU.

This function is very similar to the [Texture](/engine/6000.6/script-reference/unityengine/texture.md) constructor, except it works on a Texture object that already exists rather than creating a new one.

It is not possible to reinitialize **Crunched** textures, so if you pass a **Crunched** texture to this method, it returns `false`.  See [texture formats](/engine/6000.6/manual/materials-and-shaders/textures/textures-getting-started/texture-compression-formats.md) for more information about compressed and crunched textures.

Call [Texture2D.Apply](/engine/6000.6/script-reference/unityengine/texture2d/apply.md) to  upload the changed pixels to the graphics card.

[Texture.isReadable](/engine/6000.6/script-reference/unityengine/texture/isreadable.md) must be `true`.

`Texture2D.Reinitialize` does not automatically update the [special texture properties](/engine/6000.6/manual/materials-and-shaders/shaders/writing-custom/shader-writing/writing-shader-change-properties/sl-properties-in-programs.md) \{TextureName}`_TexelSize` and \{TextureName}`_HDR`, which Unity sets automatically on shaders and materials that use the texture. After using `Texture2D.Reinitialize`, you should update \{TextureName}`_TexelSize` and \{TextureName}`_HDR` on your material or shader if you need them.

## Reinitialize(int, int, GraphicsFormat, bool)

Reinitializes a Texture2D, making it possible for you to replace `width`, `height`, `textureformat`, and `graphicsformat` data for that texture.

```csharp
public bool Reinitialize(int width, int height, GraphicsFormat format, bool hasMipMap)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new width of the texture.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new height of the texture.**** (\[GraphicsFormat]\(/engine/6000.6/script-reference/unityengine/experimental/rendering/graphicsformat)): The new format of the texture.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether the texture reserves memory for a full mipmap chain.

### Returns

| Type                                                          | Description                                   |
| ------------------------------------------------------------- | --------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the reinitialization was a success. |

### Remarks

This action also clears the pixel data associated with the texture from the CPU and GPU.

This function is very similar to the [Texture](/engine/6000.6/script-reference/unityengine/texture.md) constructor, except it works on a Texture object that already exists rather than creating a new one.

It is not possible to reinitialize **Crunched** textures, so if you pass a **Crunched** texture to this method, it returns `false`.  See [texture formats](/engine/6000.6/manual/materials-and-shaders/textures/textures-getting-started/texture-compression-formats.md) for more information about compressed and crunched textures.

Call [Texture2D.Apply](/engine/6000.6/script-reference/unityengine/texture2d/apply.md) to  upload the changed pixels to the graphics card.

[Texture.isReadable](/engine/6000.6/script-reference/unityengine/texture/isreadable.md) must be `true`.

`Texture2D.Reinitialize` does not automatically update the [special texture properties](/engine/6000.6/manual/materials-and-shaders/shaders/writing-custom/shader-writing/writing-shader-change-properties/sl-properties-in-programs.md) \{TextureName}`_TexelSize` and \{TextureName}`_HDR`, which Unity sets automatically on shaders and materials that use the texture. After using `Texture2D.Reinitialize`, you should update \{TextureName}`_TexelSize` and \{TextureName}`_HDR` on your material or shader if you need them.
