Code: Select all
using UnityEngine;
using UnityEngine.Tilemaps;
public class BoardManager : MonoBehaviour
{
public class CellData
{
public bool Passable;
}
private CellData[,] m_BoardData;
}
private Tilemap m_Tilemap;
public int Width;
public int Height;
public Tile[] GroundTiles;
public Tile[] WallTiles;
// Start is called before the first frame update
void Start();
{
m_Tilemap = GetComponentInChildren();
m_BoardData = new CellData[Width, Height];
for (int y = 0; y < Height; ++y)
{
for(int x = 0; x < Width; ++x)
{
Tile tile;
m_BoardData[x, y] = new CellData();
if (x == 0 || y == 0 || x == Width - 1 || y == Height - 1)
{
tile = BlockingTiles[Random.Range(0, BlockingTiles.Length)];
m_BoardData[x, y].Passable = false;
}
else
{
tile = GroundTiles[Random.Range(0, GroundTiles.Length)];
m_BoardData[x, y].Passable = true;
}
m_Tilemap.SetTile(new Vector3Int(x, y, 0), tile);
}
}
}
Der Tutorial-Schritt, mit dem ich Probleme hatte: https://learn.unity.com/tutorial/66f53d ... 0669b8a16f
Ich habe versucht, mich um den leeren Anfang sowie um einige andere Zeilen herum zu bewegen, aber auf Nr verfügbar. Der Fehlercode, den ich erhalten habe, lautet wie folgt:
Top-Level-Anweisungen müssen vor Namespace- und Typdeklarationen stehen.