How to clear the screen?

I need to clear the screen using code in my openGL based plugin, before anything is drawn by Unity.

I am currently calling the plugin from within the Update method of a script attached to the camera, which is set to “dont clear”, and the screen clears to the correct color in my plugin. But, everything Unity has drawn is also gone. It appears the Update method is called after Unity has finished rendering.

How can I make sure the clear screen plugin method is called before Unity starts to render?

Solved: Had to use

void OnPreRender()

And set the camera clear to “depth only”. Also used GL.InvalidateState() after rendering from native code plugin.