void ShowMaze(Loc[,] Maze) { width = Maze.GetLength(0) - 1; height = Maze.GetLength(1) - 1; GameObject empty = new GameObject("Labyrinth"); empty.isStatic = true; empty.transform.position = new Vector3(0, 0, 0); for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) { //Если есть вертикальная стена - рисуем ее if (Maze[x, y].up_wall) (Instantiate(up_wall, new Vector3(x * cellSize, 0, y * cellSize), Quaternion.identity) as Transform).SetParent(empty.transform); //Если есть горизонтальная стена - рисуем ее if (Maze[x, y].left_wall) (Instantiate(left_wall, new Vector3(x * cellSize - 0.4f, 0, y * cellSize + 0.4f), Quaternion.identity) as Transform).SetParent(empty.transform); } //Рисуем стену снизу и справа от лабиринта for (int i = 0; i < width; i++) (Instantiate(up_wall, new Vector3(i * cellSize, 0, width * cellSize / 1.7f), Quaternion.identity) as Transform).SetParent(empty.transform); for (int i = 0; i < height; i++) (Instantiate(left_wall, new Vector3(height * cellSize * 1.7f - 0.4f, 0, i * cellSize + 0.4f), Quaternion.identity) as Transform).SetParent(empty.transform); //Рисуем пол GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane); plane.transform.localScale += new Vector3(1, 0, 1); plane.GetComponent<Renderer>().material = Resources.Load("planeMaterial", typeof(Material)) as Material; plane.transform.SetParent(empty.transform); //plane.transform.localScale += new Vector3(0.1f * (width - 11), 0, 0.1f * (height - 11)); //Debug.Log(plane.transform.position); plane.transform.position = new Vector3(width * 0.4f, -0.5f, height * 0.4f); //empty.transform.SetParent(empty.transform); }