private void initGameBoard() { float cameraSize = getCameraSize(); float scaleSprite = getScaleSprite(cameraSize); float boardX = boardColumns * scaleSprite; float boardY = boardRows * scaleSprite; float spriteX, spriteY; for (int row = 0; row < boardRows; row++) { for (int column = 0; column < boardColumns; column++) { spriteX = -(boardX / 2) + scaleSprite / 2 + column * scaleSprite; spriteY = (boardY / 2) - scaleSprite / 2 - row * scaleSprite; GameObject gridObject = Instantiate(gridPrefab, new Vector3(spriteX, spriteY, 0), Quaternion.identity); gridObject.transform.localScale = new Vector3(scaleSprite, scaleSprite, scaleSprite); boardData.initGameBoard(row, column, gridObject.GetComponent <GridElement> ()); } } }