Version: 2022.1
LanguageEnglish
  • C#

Texture2D.Reinitialize

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

Declaration

public bool Reinitialize(int width, int height);

Declaration

public bool Reinitialize(int width, int height, Experimental.Rendering.GraphicsFormat format, bool hasMipMap);

Declaration

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

Parameters

width New width of the Texture.
height New height of the Texture.
format New format of the Texture.
hasMipMap Indicates if the Texture should reserve memory for a full mip map chain.

Returns

bool Returns true if the reinitialization was a success.

Description

Reinitializes a Texture2D, making it possible for you to replace width, height, textureformat, and graphicsformat data for that texture. This action also clears the pixel data associated with the texture from the CPU and GPU.
This function is very similar to the Texture 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 for more information about compressed and crunched textures.
Call Apply to upload the changed pixels to the graphics card.
Texture.isReadable must be true.