I’ve just posted a script that lets you generate thumbnails for your GameObject’s and/or materials during gameplay and wanted to share it here, as well. The generated thumbnail is in Texture2D format and supports transparent background.
Should work on pretty much any platform that Unity supports.
FAQ
Rendered thumbnail is empty, why?
If shouldIgnoreParticleSystems parameter is set to false, child particle systems of the model may force the camera to zoom out a lot. Or, on SRPs, your Forward Renderer asset’s Opaque Layer Mask and/or Transparent Layer Mask might be excluding layer 22 (preview objects are temporarily assigned to this layer).
Rendered thumbnail doesn’t look correct, why?
If there are lighting issues and you’re generating thumbnails in Awake, try Start instead. Otherwise, try disabling post-processing effects and see if it makes any difference. If it does, then you should temporarily disable post-processing while capturing thumbnails.
This is perfect ! You saved me a big headache. This is exactly what I was searching for my inventory system.
If you are interested I would like to offer you a special account into my video game. You can find my game at www.citywars.ca. We are still far away from having a playable game but piece by piece we get further from a prototype. Your system is now part of our inventory system.
Hello! First of all, thank you so much for sharing this asset, it’s wonderful and exactly what I needed.
I am having an issue however - has anybody figured the issue with this asset and Unity 2018? After upgrading, I recall seeing an error or warning about it, and since seeing that it’s stopped working - annoyingly, there has been no error/warning since then, (I really wish I addressed it immediately - my next step is to make a new project and import to see if I can catch the error a second time) so I’m having trouble troubleshooting the issue.
I tried finding an upgrade guide for 2018 with changes/deprecation but couldn’t - if anyone could help I’d be very thankful! And I’ll post here if I find the solution myself of course.
Thanks for the help. I found that it actually no longer occurs on 2018.2.0f1. We’ve moved builds a few times in the last few weeks, so it must have been some temporary issue that resolved itself - works just fine after testing again (should’ve done that before posting. My apologies!)
Any idea about soft shadows but transparent backgrounds? My best solution so far is just having a fake shadow, a sprite, that is resized to the bounding box of the object you’re rendering, and repositioned to right below the bounding box. You can probably do it with ‘real’ shadows if you use some special shader on a plane below the object (?)
Yes you could use such a special shader ( this could be a good starting point ). However, as an object’s shadow may overflow its bounding box, parts of the shadow may not be visible in the generated thumbnail.
Hi there, I just had a question regarding this thumbnail generator. Right now I have a video player, and I save the texture of the video player to a RawImage. I want to generate a thumbnail based on the texture of the RawImage, but every time I try calling RuntimePreviewGenerator.GenerateModelPreview I get a null object.
Hi, this tool is great and I see you have a ton of other clever content available. Thank you for that!
I do have a question though, do you think there’s a way for GenerateMaterialPreview to ignore the Ambient Lighting so it always looks the same, similar to the Unity Inspector Material Preview?