Is it possible to create a custom model preview in an Editor window akin to the one displayed when an FBX is selected?

Hello all.

I’m looking for a way to show a preview of a model in an Editor window. This preview will ideally be able to play an animation that I would drag on to the window.

The only solution I can seem to think of is displaying a render texture of a camera set up to look at a model in game but this does not seem ideal as it means physically placing this in a scene when I would like to have this all done via the Editor window. If animations were to be played, it would also require the scene to be running.

To give you an idea, this is exactly what I want to show in an Editor window. This is an example of what is displayed when an FBX is selected.

10602-modelviewer.png

Thanks for your time.

Yes, you can do it by using Editor class. Check out “HasPreviewGUI, OnPreviewGUI and OnPreviewSettings”
Unity - Scripting API: Editor.OnPreviewGUI Unity - Scripting API: Editor.OnInteractivePreviewGUI

see here Unity - Manual: Custom Editors
use Editor.CreateEditor, OnInteractivePreviewGUI,OnInspectorGUI in your own custom editor

I create a object preview in my EditorWindow but it’s impossible preview a prefabs out of scene!

Ensure you have the required Visual Studio component installed that you need to work with graphics. The component is called Image and 3D model editors.

To install it, open Visual Studio Installer by selecting Tools > Get Tools and Features from the menu bar, and then select the Individual components tab. Select the Image and 3D model editors component under the Games and Graphics category, and then select Modify.

Turns out its not that hard, just make a MeshPreview: UnityCsReference/Editor/Mono/Inspector/ModelInspector.cs at e740821767d2290238ea7954457333f06e952bad · Unity-Technologies/UnityCsReference · GitHub