void Start() { if (Instance == null) { Instance = this; } grid = new List <List <Node> >(); tilemap = GetComponent <Tilemap>(); min = tilemap.localBounds.min; tilemapPos.z = 0; for (int x = 0; x < tilemap.size.x; x++) { grid.Add(new List <Node>()); for (int y = 0; y < tilemap.size.y; y++) { currentPos.x = x + (int)min.x; tilemapPos.x = x + (int)min.x; currentPos.y = y + (int)min.y; tilemapPos.y = y + (int)min.y; Node n = new Node(); if (tilemap.HasTile(tilemapPos)) { n.validIndex = true; } n.position = currentPos; n.previous = null; n.gridPos = new Vector2Int(x, y); grid[x].Add(n); } } Debug.Log(grid[0][0].position); }
private void OnDestroy() { Instance = null; }