- Home /
How to replace Texture2D.Reinitialize()? Unity 2020.3 does not have this function
I updated my Unity project to Unity 2020.3.18 and I get this error:
'Texture2D' does not contain a definition for 'Reinitialize'
According to doc, the class Texture2D suddenly doesn't have function Reinitialize() https://docs.unity.cn/2020.3/Documentation/ScriptReference/Texture2D.html
So without this function, I assume I'll have to use constructor instead?
Old code:
Texture2D tex;
int newWidth;
int newHeight;
//get newWidth & newHeight
tex.Reinitialize(newWidth, newHeight);
New code: replace tex.Reinitialize(newWidth, newHeight); with this
tex = new Texture2D(newWidth, newHeight, tex.format, false);
My question is, was my new code correct? Does it do the same thing that Reinitialize was doing?
The constructor's 4th parameter is "bool mipChain", I don't know what value I should pass for this parameter
If you are using Unity 2019.4, 2021+ versions then you can use the Reinitialize() method for changing the texture size. Choice Hotels
Answer by Namey5 · Jan 12 at 10:25 AM
I have never seen this function before and it isn't on any docs pages in the Unity archive (Unity 5+) so it was probably either a function for internal use or was deprecated a very long time ago before finally being removed. The replacement you are probably looking for is Texture2D.Resize()
https://docs.unity.cn/2020.3/Documentation/ScriptReference/Texture2D.Resize.html
Make sure to call tex.Apply() afterwards.
Answer by codemaker2015 · Apr 06 at 07:15 AM
In Unity 2020.3, the Reinitialize()
method got replaced with Resize()
So, change the following line
tex.Reinitialize(newWidth, newHeight);
like this
tex.Resize(newWidth, newHeight);
// or
tex.Resize(newWidth, newHeight, tex.format, false);
NB: If you are using Unity 2019.4, 2021+ versions then you can use the Reinitialize()
method for changing the texture size.
For more: https://docs.unity.cn/2020.3/Documentation/ScriptReference/Texture2D.Resize.html
Your answer

Follow this Question
Related Questions
Unity won't let me load an image into a texture 0 Answers
Can I import 32bpp floating point textures? 0 Answers
Applying Textures from atlas? 1 Answer
Make a texture flicker c# 2 Answers
major changes in Unity3D 4x 1 Answer