I am using the List class to store a large amount of nodes for my pathfinding grid. However if I try to go above about 7,500 objects in the List Unity almost completely freezes up. Would there be a more efficient way to keep track of this many objects?
I’d guess that many gameObjects could be the problem, when you probably don’t need them to be. Could make node be a regular class (no inherit from MonoBehavior) and create it the normal programming way:
LinkedList<Node> N;
N = new LinkedList<Node>(7500);
for(int i=0;i<7500;i++) {
N *= new Node();*
// math to set node values from whatever
}
If you actually have 7500 gameObjects, that people have hand-entered data into, you can still suck that into the Nodes at run-time and delete them.
Also, a List is good for fast anywhere inserts&deletes and OK for going from front to back. It’s pretty awful for looking in spot i (for example, if Node 106 links to 390 and 5602.) For random access like that, an array is much faster.