- Home /
Answer by Bunny83 · Oct 04, 2014 at 03:11 AM
As far as i know that's not possible. Especially since on Windows Unity (the editor as well as the runtime) uses DirectX and not OpenGL. You can of course use the "-force-opengl" commandline switch when starting the editor, but Unity isn't designed to provide an interface for external libraries.
As far as i can tell Unity should be ready to draw in OpenGL immediate mode during the OnGUI repaint event. However i never tried to direcly use native OpenGL from there. It might work.
I tried this
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(Test))]
public class TestEditor : Editor
{
private void OnSceneGUI()
{
OpenT$$anonymous$$.Graphics.OpenGL.GL.Begin(OpenT$$anonymous$$.Graphics.OpenGL.Begin$$anonymous$$ode.Triangles);
OpenT$$anonymous$$.Graphics.OpenGL.GL.Color3(1.0f, 0.0f, 0.0f);
OpenT$$anonymous$$.Graphics.OpenGL.GL.Vertex3(0.0f, 0.0f, 0.0f);
OpenT$$anonymous$$.Graphics.OpenGL.GL.Color3(0.0f, 1.0f, 0.0f);
OpenT$$anonymous$$.Graphics.OpenGL.GL.Vertex3(1.0f, 0.0f, 0.0f);
OpenT$$anonymous$$.Graphics.OpenGL.GL.Color3(0.0f, 0.0f, 1.0f);
OpenT$$anonymous$$.Graphics.OpenGL.GL.Vertex3(0.0f, 1.0f, 0.0f);
OpenT$$anonymous$$.Graphics.OpenGL.GL.End();
}
}
and Unity just crashed. I tried it with -force-opengl and also without the GL.Begin and GL.End. HELP!!!
As i said it probably won't work. However if it works at all, you must only draw stuff during the repaint event:
private void OnSceneGUI()
{
if(Event.current.type == EventType.Repaint)
{
// Your drawing stuff
}
}