This page looks best with JavaScript enabled

GL.Lines - Drawing Lines Manually in Unity

 ·   ·  ☕ 1 min read

You use Unity’s Gizmos all the time for debugging and your app. What if you want those lines in play mode? Unity Gizmos can’t render in play mode.

Lets implement our own version of a line renderer using the built in GL calls included with Unity. This will allow us to create a custom line renderer that can be used for both Gizmos and while we are playing our game. Pretty neat!

To do this we’ll leverage the GL calls I mentioned previously and take advantage of Unity’s Camera.OnPostRender() method (more info here: so we can draw our lines as a part of our scene and have them behave exactly as we intend them to.

Grab the code for this Gizmo style line renderer on GitHub here:


Sam Wronski
Sam Wronski
Maker of things and professional software engineer. Lets make something awesome together!