Drawing interconnected sprites among the line in 2D.


Imagine if you want to draw a top-down 2D road. You click or touch to your game and then drag your cursor do draw a line. Instead of line, sprites of road will appear. When your imaginary line will intersect, there will be crossroads. When your line is not straight, roads must be curved.

I thought instantiating new gameobjects with game sprites and then correct them via other script. However, having a lot of gameobjects is very harmful for perfromance.

Is there a method to add multiple sprites and correct them in one GameObject?

Is there any solutions for Unity about this in 2D?


Problem is not how to do it in Unity, but how can You do it overall. I have few tips, I hope. :slight_smile:

Few questions about performance: Aren’t You instantinating tousands of objects (every pass of loop while holding a button)? Are You using some kind of “spawner” (object pooling)?

And I assume You wan’t behaviour like in Cities:Skylines. There is first transparent, single object, and is just scaled along the way, and when You release button, road is placed. You can achieve that using three sprites? Single road, crossroad and one, created manually with for example ax^2+bx+c equation to make curves.