Material thumbnails in a widget - is it possible?

Hi!
I’m working on a pretty simple project that will allow users to walk around an apartment and “re-paint” surfaces by swapping materials.
The materials to choose from will be shown in a grid widget, containing buttons associated with materials.

The painting portion is all done and works as intended.
But I want to have previews on the buttons (currently they’re blank white regardless of the material they represent).
Obviously, I can’t just apply surface materials to the buttons, and assigning every material a 2D image to display would take me a while.

So I was wondering if it’s possible to fetch the editor’s material thumbnails for this.
They’re already there for every material and are 2D images as far as I know. Plus they will update on their own as I work.
This would be very convenient.
But I can’t seem to find a way to get a thumbnail from a material.

Is this doable or should I avoid this idea?

I can see the solution with scene capture component and render target. You have your spheres on the scene somewhere, with cameras, and render targets are used in UI materials.
There must be easier solutions that I’d like to hear about, but this one should be a working workaround :wink:

Yes for such amount of materials it should probably run badly. In this case why not put all your mats in an array, and with a for loop make screenshots and assign to your images (that can be added proceduraly as well in the same function, for each mat, take a screenshot, add an image widget, set the image of the widget)

Edit I forget to include “set the sphere material” (and take screenshot after)

Hi Grot13,

Thanks for the advice. I was definitely considering this.
But the list of materials to choose from could get pretty long (approximately 20-30)
Wouldn’t I have to have dozens of these spheres then? And wouldn’t making this many render targets tank performance?