netpyoung / unity.webp

:art: WebP made easy for Unity3d
https://netpyoung.github.io/unity.webp/
MIT License
237 stars 28 forks source link

Pointers #29

Closed lexonegit closed 2 years ago

lexonegit commented 2 years ago

In example 2 there's code for decoding a webp animation. Is there a way to do it without using c# pointers? (unsafe code)

I'm asking because the decoding process can freeze up the whole app momentarily. The cause of this seems to be the Texture2D generation, which is slow and it also runs on the main Unity thread -> logically freezes the whole app.

In order to avoid that I could "stretch" the Texture2D generation process into multiple frames using Unity's coroutines. The problem is that I can't get coroutines to work alongside the unsafe code. Not sure if it's even possible?