How do I select gizmos by mouse clicking in the editor?

So I have a gameobject with a script attached, there is a variable ‘nextWaypoint’. When there weren’t many waypoint objects, I just assigned the variable to each waypoint manually, but now I have so many waypoint objects. How can I code an editor script behavior so that I can click on the gizmo of the next waypoint object and assign it to the variable in the script?
Thank you for your help

i made something like this a while back using linear waypoints (so no tree structures and no looping), and i just made sure that the game objects that where being used as waypoints where in a heirarchy, and that they where ordered correctly, then a the heirachy parent grabbed all the child objects in order, and i got my waypoints from that.