An approach to adding wireframes to your objects in Unity without the use of shaders. I wrote this specifically so that I could filter our the diagonal lines from quadrilateral surfaces. The implementation is pretty simple and uses GL.LINES and GL.QUADS for rendering.
Only WireframeRenderer.cs is required, but the contents of the Assets/Editor folder are recommended for ease of use.
- Attach the WireframeRenderer component to your GameObject(s). Note that a MeshFilter component is required.
- Use the buttons in the inspector to prepare the wireframe. This generates a list of line segments that get serialised with the script.
- The wireframes will be visible in Play Mode.
"Lines" uses GL.LINES, which limits this mode to single-pixel wide rendering. The width parameter has no effect.
"Quads" uses GL.QUADS, which do have a configurable width.
When using quads, the geometry of the wireframe will create visible artifacting if you're also using a mesh renderer. To avoid that, you can use the shader and material provided for the wireframe (see example scene). The shader simply forces an offset in the depth buffer.