'unity serialization depth limit exceeded'

Hello!

I am working on a RTS pathfinding script. It’s basic elements are nodes, which contain a bunch of data, such as coordinates, as well as a list to other nodes they are connected to. My problem is, if i try to do something like this:

class PathfindingNode{
   var connectedNodes:List.<PathfindingNode>;

   function PathfindingNode(){

   }
}

i get this error message: ‘unity serialization depth limit exceeded’. I tried to read up on it, and i know it’s caused by the class trying to contain a reference of it’s own type. But how other way could i store node connectivity data? Each node can be connected with multiple other nodes, forming a network along which the pathfinding algorithm would work.

Also, the same system works perfectly fine, if instead of a custom class i use game objects with a script attached to them.

Simply tag the list with NonSerialised.

Does it not lose it’s contents then? I forgot to add in the starting post: That list is actually pre-populated by an editor script that processes the map, not while running the game.