C# Tablice wielowymiarowe Unity

        string board = "";

        string[,] chessboard = new string[8, 8];

        for (int r = 0; r < chessboard.GetLength(0); r++)
        {
            for (int c = 0; c < chessboard.GetLength(1); c++)
            {
                chessboard[r, c] = $"{r} {c}";
                board += chessboard[r, c] + "  ";
            }
            board += "\n";
        }
        Debug.Log(board);

Tablica wyświetlająca pola jak na szachownicy

        for (int r = chessboard.GetLength(0); r > 0; r--)
        {
            for (int c = 0; c < chessboard.GetLength(1); c++)
            {
                chessboard[r-1, c] = $"{Convert.ToChar(c + 97)} {r} ";
                board += chessboard[r-1, c] + "  ";
            }
            board += "\n";
        }

        Debug.Log(board);
Scroll to Top