How it all began?
Many of you know the standard Unity Line Renderer component. It draws a line based on the points which you set it in. It is a really good renderer, but … a generated line always faces the camera. There is no way to make your line visible normally, from the perspective. That was the main reason that motivated us to write the Line Renderer Pro.
In the first phase of this project, we’ve tried to think of what else can be added to the new line renderer. First good idea: Line point colors. Second good idea: Line width per point (unlike in the Unity Line Renderer, where the user can only set the start and end width). Designing is done – let’s start programming!
Mesh generation wasn’t simple but it also wasn’t very hard. Quaternions helped us a lot with vertex transformations as they combine functionality of directions and rotation. All in all, we’ve finished the mesh generator and started working on the UVs.
UV – the weirdest and hardest thing
So yes – placing UVs correctly on the mesh was the hardest thing to implement in Line Renderer Pro. The problem was the perspective and correct texturing of the trapezoid. Below images illustrate the problem:
After searching through the web, we’ve finally found this – http://forum.unity3d.com/threads/correcting-affine-texture-mapping-for-trapezoids.151283/
It helped a lot. Immediately, we’ve implemented it into the Line Renderer Pro. But there was one problem. This solution requires a specially prepared shader – so, we’ve downloaded the sources of Unity built-in shaders and modified the most important ones (Standard shader and Unlit), to support the Line Renderer Pro.
Trust us – it was the easiest thing to make. By using Handles class, we’ve made a cool scene editor. Also, a class called ReorderableList helped us in making a comfortable inspector editor. As we’ve made all of the data changing operations using the SerializedObject and SerializedProperty, it also supports undo and redo functionality.
Making this plugin seemed to be really easy in the beginning, but due to UV mapping it became slightly more difficult. Fortunately, everything went fine and we, The Knights of Unity, are able to present you the Line Renderer Pro! 🙂