How do I get a handle for the SceneView so I can draw in it with OpenTK?

Hi, is it possible to get a handle to the SceneView (or similar method) so I can draw in it with OpenTK. Thanks.

1 Answer

1

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.

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 } }

That still crashes Unity.