Generating preview thumbnail for custom asset

I’ve been developing a plugin for a custom asset type for the game I’m working on. Currently when an asset of my custom format is imported the preview thumbnail in the content panel is blank. I’d like to generate a thumbnail for it. I haven’t been able to find any documentation for how to do so.

I’ve been trying to use ThumbnailTools::CacheThumbnail in my asset factory to assign a thumbnail, which as best as I can tell is how other systems assign thumbnails, including ContentBrowserUtils::CaptureThumbnailFromViewport. Unfortunately the thumbnail preview is still blank, and upon tracing through the code I see at some point the editor is assigning an empty thumbnail even though one has already been assigned.

Can anyone help with how I can assign an image as the thumbnail for an imported asset for my custom asset importer?

I eventually managed to get a thumbnail working last night. You need to implement a ThumbnailRenderer class that knows how to render your thumbnail and draw it to a Canvas object, and register it in your module as handling your custom type. Drawing on the canvas didn’t work as expected; most notably alpha didn’t seem to work properly.

I didn’t see this documented anywhere and looking through the code it seems several things create thumbnails without it. There should really be a tutorial or basic documentation on how to do this.

1 Like