- Home /
Get default preview for GameObject Editor
So I created a custom Editor that ABSOLUTELY must be a GameObject editor, I.E. it replaces the base editor for GameObjects. I used the OnInspectorGUI override and base.DrawDefaultInspector() to get the default inspector back. However I cannot for the life of me get the preview to show up, and it even makes the preview icons turn back into blue boxes.
So far I have tried the following thiongs. Attempted to draw a custom preview, no success without drawing a literal custom preview, this will never bring icons back. Tried including the base.OnPreviewGUII. Tried including the base.OnInteractivePreviewGUI. Tried including the base.OnPreviewSettings. Tried using OnGUI to draw the preview from editor... still no luck. Tried incorporating ALL of the above at once, no luck. Any ideas? People are going to be very unhappy when they realize that my extensions does not show preview GUI.
Any thoughts? @Bunny83
Answer by Adam-Mechtley · Jan 20, 2017 at 07:19 PM
Please see my answer here.
The problem is that you need to re-implement Editor.RenderStaticPreview(). Simply calling the base implementation will not help you because you are not inheriting from the built-in GameObjectInspector class, but simply Editor, which will just draw a cube icon instead of a preview of the renderers.
The best workaround for now is to create an instance of the built-in GameObjectInspector (via reflection) using your same targets in e.g., OnEnable, and call RenderStaticPreview on this instance and return its result in your method.
This actually worked to get the icons back, but I still can't get the preview box to render a preview of the object like it should for 3d objects. I know how to render a new preview of the object, but this won't replace the existing preview window, it just adds another preview and I'm stuck with a broken preview below it.
Answer by startassets · Mar 12, 2017 at 07:46 PM
@RobAnthem I've just finished my own preview asset, maybe it will be useful for you: https://forum.unity3d.com/threads/powerful-preview.460157/