Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by cdr9042 · Jan 12 at 08:39 AM · texture2d

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Olivia69 · Apr 06 at 10:18 AM 0
Share

If you are using Unity 2019.4, 2021+ versions then you can use the Reinitialize() method for changing the texture size. Choice Hotels

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

141 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to Add texture image behind or below a 3D model with second camera? 0 Answers

Does Unity Create Multiple Atlases if I Slice a Texture > 4096x4096? 0 Answers

How do you crop a Texture2d 1 Answer

Shader:DX11 get texture dimensions inside a shader 1 Answer

Layered Billboard Sprite 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges