// Use this for initialization void Start() { NodeList = new List <List <Node> >(); //Init list int SizeX = (int)theGridMap.GetGridSize().x; int SizeY = (int)theGridMap.GetGridSize().y; for (int i = 0; i < SizeX; i++) { NodeList.Add(new List <Node>()); } // Fill up NodeList for (int i = 0; i < SizeX; i++) { for (int j = 0; j < SizeY; j++) { Node toAdd = new Node(); toAdd.Init((int)theGridMap.GetGridCost(i, j), theGridMap.GetVec3Pos(i, j)); NodeList[i].Add(toAdd); } } }