How can I create a custom AssetPreview for a prefab

The core of the question is, how can I customize the Texture that is returned by the AssetPreview.GetAssetPreview method?

A detailed explanation of my use case follows:

I have some prefabs that contain a components that creates a mesh from sprites info and some data. (its a tool similar to spine, spriter, etc)

Right now I am making a custom level editor, and in the palette tool I am showing prefabs with the AssetPreview, so using AssetPreview.GetAssetPreview (item.gameObject) I am able to show a nice icon for the prefabs.

This works perfectly for prefabs that have just regular sprites in them, like, trees, rocks, houses, grass decals, etc, but when I want to add a prefab that is a character using our custom mesh based component the preview is not generated. Even in the project view when using the resize slider, the sprite based prefabs show nice icons, but the character prefabs show just the default prefab icon.

I tried using the CustomPreview attribute and ObjectPreview class to generate a preview using OnPreviewGUI and OnInteractivePreviewGUI but even though they work fine in the preview view of the inspector, they fail to work on the project view, or the AssetPreview.GetAssetPreview method call.

Thanks for any information

Hi @rubeng! So this is not documented very well, but AssetPreview.GetAssetPreview () is actually looking for your definition of Editor.RenderStaticPreview () on the custom editor class defined for the target type in question.