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?
asked Dec 17 '11 at 02:55 PM
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:
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.
answered Dec 17 '11 at 08:45 PM