Exemple #1
0
    public void GenerateGrid()
    {
        //clears grid before creating new one
        ClearGrid();

        _num = 0;
        //Sets the lenght of array
        cellList = new GameObject[width * height];

        //double for loop to generate 2d grid
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                //create object and add to array
                GameObject _cellObj = Instantiate(_cell, transform);
                _cellObj.transform.position = new Vector2(j, -i);
                cellList[_num] = _cellObj;
                _num          += 1;
            }
        }

        //resize cam after new grid gen
        _camView.ResizeCam();
    }