Create dynamic graphs in unity

Hello,

I’m creating a 2D top-down game thingy for a school assignement.
I know C# but I am quite new to the unity environment, so forgive me if this isnt the proper place to post this question.

Anyway, I made a small racetrack by drag-and-dropping prefabs with sprites, it looks like this:
Click to view image

Now I need to somehow make a graph out of this so I can connect nodes and w/e.
But my problem is as follows:
Most 2D games have a node in each tile, which is the most easy way to create a graph. In this game thing I want a node on each lane of the road, this way the pathfinding would be available on both lanes.

I assume one way to handle this is to loop through the height and the width of the screen and check if the x and y are located within the bounds of a prefab, but I believe there should be a better way to do this.

If anyone could assist me or give me tips on where to find a solution and/or tutorial, that’d be great.

I currently do not have any code since I want to know how to approach this subject first.

Thanks!

TL;DR What would be the best and most efficient way to create a graph within my ‘race track’?

You could place empty gameobject as a ‘node point’ for each road piece prefab…

or if the track is not procedural, just manually add empty gameobjects as nodes over the ready track, like, and then can access them easily with transform.GetChild()
2990601--222655--upload_2017-3-12_20-15-59.png

Thanks for your reply!
I’ll play around with this for now!