- Home /
Any way to hook into the start of a frame, or to have GUI elements write to the depth buffer?
I'm writing a Unity Pro plug-in for water that renders directly to Unity's underlying Direct3D or OpenGL context for PC targets. Unity's sample code for doing this relies on
yield return new WaitForEndOfFrame();
in order to hook into a point where the correct device is active, and a plugin may safely draw to it.
The problem is that by drawing at the end of the frame, my geometry ends up drawing over any GUI elements, since it seems GUI elements do not write to the depth buffer.
I can think of two solutions - is either possible?
Is there any way to get GUI elements (such as GUI.Box) to write to the depth buffer?
Is there any way to hook into the beginning of the frame, instead of the end? There doesn't seem to be a WaitForStartOfFrame for some reason. Actually, a hook into any point before GUI elements are drawn would work for me.
Thanks!
Frank Kane - Sundog Software LLC