/// <summary> /// Instantiate a new grid of cells in a square, taking their size into account for cell placement. Then recalculates the placement of all environment objects. /// </summary> public void GenerateGridInEditor() { DestroyGridInEditor(); grid = new Cell[Size, Size]; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { CreateCell(x, y); } } GameObject[] envObjects = GameObject.FindGameObjectsWithTag("Environment"); for (int i = 0; i < envObjects.Length; i++) { SnapToMap snappableObject = envObjects[i].GetComponent <SnapToMap>(); if (snappableObject != null) { snappableObject.OccupyCell(); } } }