I am trying to make a graph and showing/making it easier to edit using a custom editor and some gizmos. So far I thoguht that the graph could be done with some nodes, and each node stores the adjacent ones inside a list (and I found no problems to this point). The code stores a public “out” list referencing the nodes I can go from this one and a private “in” list referencing the nodes that come to this one. (only the “out” nodes can be modified).
When adding/deleting adjacent nodes I want the node added/deleted have its connections updated too (if I add an adjacent node to a node, I want the other node updated adding a new “in” to the list referencing this node and when deleting it I want to delete that “in” connection of the other node).
Now, what I’ve done is create a copy of the list on the “onInspectorGUI()” function and wait until the GUI changes (using “GUI.changed”). Then I compare the previous list with the current one to try and find out which node went out and update them all but I have to look first if a node was added or deleted and then compare one list with the other and then find the nodes on the lists and update them.
How can this be done in a better way? Is there any way to know what element of the custom list was the one modified?
I’ve tried to search for the current element in the inspector that is focused but looks like unity does not give this information I think, but knowing that the operations could be much faster.