// Start is called before the first frame update private void CreateLevel() { for (int y = 0; y < _tileMap.Count; y++) { for (int x = 0; x < _tileMap[y].Count; x++) { GameObject tile = SpawnObject( Instantiate(_prefabManager.GetTilePrefab(_tileMap[y][x])), "tile_" + x + "_" + y, new Vector3Int(x, y, 0) ); tile.SetActive(true); if (_tileMap[y][x] == 1) { tile.transform.SetParent(_terrainTilesGroup.transform); } else if (_tileMap[y][x] == 0) { tile.transform.SetParent(_pathTilesGroup.transform); } } } Quaternion currentRotation = transform.rotation; transform.rotation = Quaternion.Euler(0f, 0f, 0f); _bounds = new Bounds(transform.position, Vector3.zero); foreach (Renderer tileRenderer in _terrainTilesGroup.GetComponentsInChildren <Renderer>()) { _bounds.Encapsulate(tileRenderer.bounds); } Debug.Log("The bounds of this model is " + _bounds); transform.rotation = currentRotation; Camera.main.transform.position = _bounds.center; Camera.main.GetComponent <CameraZoom>().MaxOrtho = _bounds.center.x * 1.5f; Camera.main.GetComponent <CameraZoom>().ApplyOrthoLimits(); Camera.main.GetComponent <CameraMovement>().Bounds = _bounds; }