I’m trying to render ‘advanced’ geometries in an editor window.
I was able to use the GL class, like it is described in the documentation, to display simple things like QUADS or LINES.
But I would like to directly render meshes (more efficient if multiple instances & same result as in game if you cook some data).
The candidate I found is the Graphics class. But whatever I’m trying, I can’t see anything in my editor window. I’m not sure of the meaning of the parameters you can give to Graphics: Matrix? But relative to which Camera, if you are in an editor window?
Is it really something you can use here?
Did anyone already successfully use Graphics in an Editor window?
As far as i remember the Graphics class is a pro only feature, at least most methods in it. Also make sure you draw them during the Repaint event. However for free users you can still simply use a camera to draw something to an EditorWindow. Just call cam.Render inside your OnGUI method during the repaint event. Keep in mind when setting up temporary cameras / lights / objects to create them with hideflags “dontsave”. Also when no longer using those objects you should destroy them with DestroyImmediate.
if you have Unity pro and want to use DrawMeshNow, make sure you have:
set a shader pass of a material
have setup the viewport (GL.Viewport)
have setup some projection (GL.LoadOrtho / GL.LoadPixelMatrix / GL.LoadProjectionMatrix)