- Home /
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.
Thanks for your time.
You can get a preview like this:
Is that enough?
Answer from xanaxknight converted to comment:
Unfortunately, I would need more or less exactly the style of window shown in my screenshot, with the ability to translate the camera around the model and such. Thanks anyway.
Answer by jasonlu00 · Jul 15, 2015 at 07:19 PM
Yes, you can do it by using Editor class. Check out "HasPreviewGUI, OnPreviewGUI and OnPreviewSettings" http://docs.unity3d.com/ScriptReference/Editor.OnPreviewGUI.html http://docs.unity3d.com/ScriptReference/Editor.OnInteractivePreviewGUI.html
Thank you for this, here is another link to look at (read 9.8, google translate works with Japanese translation, really cool tutorial) http://anchan828.github.io/editor-manual/web/customeditor.html
also this one, is more towards animation http://anchan828.github.io/editor-manual/web/spri$$anonymous$$nimationpreview2.html
Answer by CrazyDoctor · Feb 25, 2014 at 01:24 PM
see here http://docs.unity3d.com/Documentation/Components/editor-CustomEditors.html use Editor.CreateEditor, OnInteractivePreviewGUI,OnInspectorGUI in your own custom editor
Answer by conceptfac · Aug 04, 2020 at 12:32 AM
I create a object preview in my EditorWindow but it's impossible preview a prefabs out of scene!
Answer by TJHeuvel-net · Jan 11 at 07:32 PM
Turns out its not that hard, just make a MeshPreview: https://github.com/Unity-Technologies/UnityCsReference/blob/e740821767d2290238ea7954457333f06e952bad/Editor/Mono/Inspector/ModelInspector.cs#L249