Storing additional data in custom graph nodes

we are programming an isometric 3D game in Unity, and studying the viability of this product, some doubts have arisen.

We would need to know if it is possible for the grid to work with custom GraphNodes that store additional information of our game, and if so what would be the way.

From what I have seen in the tutorials we suppose that the type of graph that we would use is the GridGraph or the LayeredGridGraph (our scenarios contemplate several floors).

We would also need to know how to save/load this information in the same way that the mesh cache is saved.

Thanks in advance.


Usually Iā€™d recommend against modifying the package code.
Instead what is usually better is a dictionary mapping between nodes and your data Dictionary<GraphNode, MyAdditionalData>. Would that work in your case?
In the beta it is also possible to override the actual node type by subclassing the graph.

Hi Aron, thank you very much for your reply.

Working with a dictionary will probably have a negative effect on performance, as we will probably use a high data density.

In the end I tried something similar to what you said in your answer. Inheriting from the GridGraph and GridNode classes, and overriding the ScanInternal(), SerializeExtraInfo() and DeserializeExtraInfo() functions I can get something similar to what I was looking for.

1 Like