public void BuildMap() { m_map = new MapData(MapSizeX, MapSizeZ); for(int i=0; i<MapSizeZ; k++) { m_map[i, k] = new MapData(); } } GameObject[] nodes = (GameObject[])GameObject.FindGameObjectsWithTag()("gridnode"); foreach(GameObject nodeobj in nodes) { GridNode node = nodeobj.GetComponent<GridNode>(); Vector3 pos = nodeobj.transform.position; if((int)pos.x >= MapSizeX || (int)pos.z >= MapSizeZ) { continue; } m_map[(int)pos.x, (int)pos.z].fieldtype = node._mapData.fieldtype; }