- Lea Hayes
- Rotorz Limited
- From: United Kingdom
- Registered: 2014-03-04
- Posts: 638
Originally I was using an internal editor-only Unity API to draw asset previews which was eventually exposed as AssetPreview.GetAssetPreview.
Due to various difficulties I ended up rolling my own thumbnail rendering which is accomplished by setting up a "mini scene" and rendering to a render texture. When I say "mini scene" what I mean is that an instance of the prefab is created along with a camera and light source; these objects are placed onto an unused layer and the camera is blind to everything except this unused layer thus avoiding the rendering of anything else in the scene. To avoid dirtying the scene the appropriate hideFlags value is used.
To avoid unnecessary performance issues the thumbnails are cached which gets refreshed whenever changes to the asset file are detected or whenever the user uses the "Refresh Preview" menu item on the brush.
I hope that this helps with your question!