- Home /
Connect pathfinding nodes in editor using gizmos
I have setup a series of empty objects and attached pathfinding vertex controllers to each. I have setup the script to show me lines between the connected vertices and to provide more information when selected.
But the actual process of connecting vertices is tedious at best and infuriating at worst. I would LOVE to connect vertices simply by selecting one, then holding shift, and clicking on the next one. This should create an automatic connection (or even better, show me a message box asking what type of connection I want). Is there a way to do this? Or do I need to continue to edit an array of serialized connection objects in the inspector?
Answer by Bunny83 · Sep 29, 2019 at 03:05 AM
Well, you can create either a custom editor tool, a custom editor window or a custom inspector that provides this functionality depending on how your "links" are actually implemented. Since we don't know anything about how your "pathfinding vertex controller" looks like and how it actually established the link we can't really help you with your specific case.
Creating such an editor tool requires a little bit of work. However it will of course simplify the editing in the future. One of the simplest solutions I can think of is using OnDrawGizmos / OnDrawGizmosSelected directly inside your node class. You could simply use a modifier button or hotkey to initiate the link creation. Combined with a static variable which references the "current" / last node you can do the linking inside OnDrawGizmosSelected when a new node is selected. If there are different link modes you could open a simple custom editor window as popup window which will let the user select the wanted link type / mode.
If you need more help with this you have to give us more details how your "node" looks like and how you want them to be connected logically.
Perfect, exactly the right direction I needed to take. Thanks!
Your answer
![](https://koobas.hobune.stream/wayback/20220612212746im_/https://answers.unity.com/themes/thub/images/avi.jpg)