After trying to wrap my head around procedural mesh generation in Unity for hours and failing repeatedly, I decided to use Unity’s Line Renderer instead of generating a real mesh. Besides being easier by orders of magnitude it also helps keeping the polycount down, while offering good visuals, although it seems to ignore most of my material’s properties. Not sure if I can get this under control. I kept the curves I calculated, and created an empty for each sub-Spline with a Line Renderer Component using the points calculated for the respective subspline.
Here is the finished code. Sadly it doesn’t have the instant feedback in the Editor anymore, but I had to remove the ExecuteInEditMode. The objects created weren’t cleaned up properly when returning from PlayMode. If I find a way to have both, I will update the code.
Read More »