Asset Preview
Where previews show up
- Inspector — select a texture, material or model in the Assets panel and the Inspector shows a live preview above its import settings: textures as images, materials on a lit swatch, and models rendered and framed to fit.
- Asset browser — image files show a thumbnail next to their name; other kinds show an icon for their type.
Previews use the same renderer as the Scene view, so a material looks as it will in the game.
Previewing your own asset types
A project can add previews for its own asset types without referencing the editor. Implement one of the engine's
preview interfaces and register it with [AssetPreview]:
| Interface | Use it when | You return |
|---|---|---|
ITexturePreviewProvider |
the asset is best shown as an image | a Texture |
IScenePreviewProvider |
the asset needs a lit 3D render | an AssetPreviewScene: a node tree and its bounds |
namespace Usercode;
[AssetPreview(typeof(TerrainAsset))]
public sealed class TerrainPreview : IScenePreviewProvider
{
public AssetPreviewScene BuildPreview(Asset asset, Vulkan vulkan)
{
var root = new Node { Name = "Preview" };
// … add a mesh node for the terrain and a light …
return new AssetPreviewScene(root, new Bounds(-Vector3.One, Vector3.One));
}
}
Studio frames the returned Bounds, renders the scene, and disposes OwnedResources when the selection changes.