Well, what I get from the code is that he actually provides that _tubePoints
array with points in space and he wants to generate a “tube” around / along those points.
Well I already told you want your issue is and essentially how to fix it. If you have trouble envisioning it in your head, I highly recommend that you take a piece of paper and draw out a simplified version so you actually understand yourself what you’re doing. I’ve even created some diagrams in MS Paint in the past to explain certain concepts back on Unity Answers.
This was specifically about subdividing a shared mesh and what happens when you actually have a duplicated / split vertex like vertex 1 and 6.
Think through your code and use a small number of segments, something like 4 which makes it easier to run through it in your head. When the math is all correct, it would scale up just fine to 10 or 100 segments.
You also may find better names for your variables so you actually know what they refer to. Since you actually create quads around your tubes, you may want to call one quad count per ring or something like that. The vertex count per ring is usually +1 the quad count when you have a duplicated vertex, otherwise it would be the same. It’s crucial that you understand your own code. So make sure you pick proper and descriptive names and make some drawings to understand what you’re doing. When I made this Rubik’s cube script, I actually inserted an ascii-art drawing of a cube to remember where which array element is located. Otherwise the actual spatial mapping would have been a nightmare. So at each layer mapping I could just look at this and going around a face in the right order to create the mappings for each layer / face.