Skip to content

Commit 139d5b2

Browse files
committed
Use Texture2D.Reinitialize instead of Texture2D.Resize from Unity 2021.1 onward
1 parent 663b042 commit 139d5b2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Fixed
44
- Fix Burst complain about two containers maybe aliasing in FilterMipmapJob.
5+
- Use `Texture2D.Reinitialize` instead of `Texture2D.Resize` from Unity 2021.1 onward.
56

67
## [0.1.1] - 2021-07-30
78
### Added

Runtime/ImageImporter.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ public async Task<Texture2D> CreateNewTextureAsync() {
109109
public void LoadIntoTexture(Texture2D texture) {
110110
using (LoadIntoTextureMarker.Auto()) {
111111
var mipmapCount = CalculateMipmapCount(true);
112+
#if UNITY_2021_1_OR_NEWER
113+
texture.Reinitialize(_width, _height, _textureFormat, _loaderSettings.generateMipmap);
114+
#else
112115
texture.Resize(_width, _height, _textureFormat, _loaderSettings.generateMipmap);
116+
#endif
113117
var rawTextureView = texture.GetRawTextureData<byte>();
114118
LoadRawTextureData(rawTextureView);
115119
ProcessRawTextureData(rawTextureView, mipmapCount);
@@ -120,7 +124,11 @@ public void LoadIntoTexture(Texture2D texture) {
120124

121125
public async Task LoadIntoTextureAsync(Texture2D texture) {
122126
var mipmapCount = CalculateMipmapCount(true);
127+
#if UNITY_2021_1_OR_NEWER
128+
texture.Reinitialize(_width, _height, _textureFormat, _loaderSettings.generateMipmap);
129+
#else
123130
texture.Resize(_width, _height, _textureFormat, _loaderSettings.generateMipmap);
131+
#endif
124132
var rawTextureView = texture.GetRawTextureData<byte>();
125133
await Task.Run(() => LoadRawTextureData(rawTextureView));
126134
ProcessRawTextureData(rawTextureView, mipmapCount);

0 commit comments

Comments
 (0)