Exemple #1
0
    private void CreateGrid()
    {
        for (int y = 0; y < gridSize.y; y++)
        {
            for (int x = 0; x < gridSize.x; x++)
            {
                //Saves the current coordinates for later use
                Vector2Int _currentCoordinate = new Vector2Int(x, y);

                //Creates a block, then adds the Block script to the object
                GridBlock _newBlock = Object.Instantiate(blockPrefab, new Vector3(x, y), Quaternion.identity, gameController.transform).AddComponent <GridBlock>();

                //Initializes the newBlock with the Vector2Ints
                _newBlock.Initialize(_currentCoordinate);
                _newBlock.AssignMaterial(GameController.baseMaterial);

                allBlocks.Add(_currentCoordinate, _newBlock);

                if (y < gridSize.y - 3)
                {
                    meshOutliner.OutlineMesh(_newBlock.gameObject);
                }
                else
                {
                    //FIXME
                    _newBlock.gameObject.layer = LayerMask.NameToLayer("Invisible");
                }
            }
        }
    }