Ich habe Probleme mit einem Unity-Learn-Tutorial zu Top-Level-AnweisungenC#

Ein Treffpunkt für C#-Programmierer
Guest
 Ich habe Probleme mit einem Unity-Learn-Tutorial zu Top-Level-Anweisungen

Post by Guest »

Als ich ein Unity Learn-Tutorial zur 2D-Rougelike-Erstellung durchging, stieß ich auf ein Problem mit Top-Level-Anweisungen, für das ich keine ähnlichen Lösungen finden konnte. Der Code, mit dem ich Probleme hatte, lautet wie folgt:

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);
}
}
}
Das Problem wird als Fehler von void Start(); Zeile, aber kein noch so großes Basteln konnte das Problem beheben.
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.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post