Hello everybody.
Since the Watchdog is nearing closer and closer I stumbled upon a few issues with texture-intensive addons. The solution I came up with for ImhoBags is general enough that I squeezed it in a library, hoping to help others who have problems with the Watchdog and texture loading.
So I present: LibAsyncTextures!
It is available at CurseForge and RiftUI.
What does it do? Well let me quote the summary:
The library adds a new method to Texture widgets:LibAsyncTextures makes it possible to have all your textures loaded in the background asynchronously, thus enabling you to load texture-rich frames without risking the Watchdog barking at you and lifts you of the burdon of having to deal with coroutines and stuff.
Texture:SetTextureAsync(source, texture[, callback])
This method enqueues the given frame for asynchronous texture loading. The function is non-blocking and returns immediately, loading the texture content at a later time. The source and texture parameters are the same as in SetTexture. You can optionally add a callback to get called when the texture finished loading. It receives frame as its only parameter. You should not perform time intensive tasks in the callback.
Example:
As the callback parameter is optional you can use SetTextureAsync as a drop-in replacement for SetTexture.Code:local texture = UI.CreateFrame("Texture", "Example texture", parent) texture:SetTextureAsync("MyAddon", "textures/example.png", function(frame) print("done", frame) end)
There are other functions and details on how the library works I suggest reading the description at your favourite developer site.
Hope you enjoy it and find it useful!


Reply With Quote


Bookmarks