Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Error CS1002

Discussion in 'Getting Started' started by ReasonableChoice, Apr 28, 2024.

  1. ReasonableChoice

    ReasonableChoice

    Joined:
    Apr 26, 2024
    Posts:
    1
    I was following a tutorial but when I finished putting the code I got an error and I don't know what's wrong.


    public class Chessboard : MonoBehaviour
    {
    private const int TILE_COUNT_X = 8;
    private const int TILE_COUNT_Y = 8;
    private GameObject[,] tiles;

    private void Awake()
    {
    GenerateAllTiles(1, TILE_COUNT_X, TILE_COUNT_Y);
    }

    private void GenerateAllTiles(float tileSize, int tileCountX, int tileCountY)
    {
    tiles = New GameObject[tileCountX, tileCountY];
    for (int x = 0; x < tileCountX; x++)
    for (int y = 0; y < tileCountY; y++)
    tiles[x,y] = GenerateSingleTile(tileSize, x, y);
    }
    private GameObject GenerateSingleTile(float tileSize, int x, int y)
    {
    GameObject tileObject = new GameObject(string.Format("X:{0}, Y:{1}", x, y));
    tileObject.transform.parent = transform;

    return tileObject;
    }

    }
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,448
    Accidental capitalization of
    new
    . Your IDE should have hightlighted this with a red squiggly line.
     
    ReasonableChoice likes this.
  3. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    1,978
    Please also learn to use the code tags this forum provides to make your code be more readable