public void InstantiateLayer(TileLayer layer) { Tile[][] __tiles = layer.getLayer(); int x = layer.LayerWidth(); int y = layer.LayerHeight(); tiles = new GameObject[x][]; for (int i = 0; i < x; i++) { tiles[i] = new GameObject[y]; for (int j = 0; j < y; j++) { Tile __tile = __tiles[i][j]; GameObject __tileGO = __tile.getMyTile(); tiles[i][j] = Instantiate(__tileGO, layer.GetDistance(i, j, x, y, __tile.width(), __tile.height()), Quaternion.identity, gameObject.transform); } } }