atteneder / KtxUnity

Load KTX and Basis Universal textures at runtime
Apache License 2.0
223 stars 42 forks source link

KTX Basis textures fail to load in editor in Unity 2021.1.0f1 & 2021.2.0a10.1508 #36

Closed DerrickBarra closed 3 years ago

DerrickBarra commented 3 years ago

Hey again @atteneder, making sure you have plenty of bugs to work on when you get back :)

So in Unity 2021.1.0f1 (the latest stable version from the Unity Hub at the time of this post), .basis textures fail to load in the Editor when loading with KTXUnity 1.0.

image

You can see in the image above, I'm using the KTXUnity-Tester github, and upgraded it to 2021.1.0f1 on my local instance for testing.

After that I just press the play button on the testing scene to encounter the error.

DerrickBarra commented 3 years ago

Oh, and just tried it on Unity 2021.2.0a10.1508, which was the latest alpha from Unity hub today. The same error exists for KTXUnity in the editor.

image

DerrickBarra commented 3 years ago

So turns out this bug was due to a change in how UnityWebRequests work in 2021.1.0f1. The script in the test repo will try to cache the .basis bytes via a WebRequest downloadHandler.data. However that is now null in the newest Unity releases so it can't be used for caching. When this caching logic is commented out, the .basis files load fine, so clearly it's not an issue with KTXUnity.

image

atteneder commented 3 years ago

Sorry for the late reply.

Great that you found the problem. Might be useful to know for the future.

Thanks!