private void MoveLoadedSectionVertically(bool _up)
    {
        int row;

        if (_up)
        {
            row = terrainDimension - 1;
        }
        else
        {
            row = 0;
        }

        //move the center up by one step
        if (_up)
        {
            currentStoragePosition = new Vector2Int(currentStoragePosition.x, currentStoragePosition.y + 1);
        }
        else
        {
            currentStoragePosition = new Vector2Int(currentStoragePosition.x, currentStoragePosition.y - 1);
        }

        //try to load the currently stored chunks
        ReloadChunkArrayFromStorage();

        int halfDim = GetTerrainDimCenter();

        //check if any of the loaded chunks is still null and if so, generate them
        for (int i = -halfDim; i <= halfDim; i++)
        {
            if (terrainChunks[i + halfDim, row] == null)
            {
                //Debug.Log(terrainChunks[i + halfDim, row]);
                terrainChunks[i + halfDim, row] = new TerrainChunk(TerrainData.GetRandomTerrainByFrequency(),
                                                                   new Vector3(planetData.GetTerrainSize().x *i, 0, planetData.GetTerrainSize().y *(row - halfDim)) + currentCenter,
                                                                   planetData.GetTerrainSize(),
                                                                   this);

                if (_up)
                {
                    terrainChunkStorage.AddAbove(currentStoragePosition.x + i, currentStoragePosition.y + halfDim - 1, terrainChunks[i + halfDim, row]);
                }
                else
                {
                    terrainChunkStorage.AddBelow(currentStoragePosition.x + i, currentStoragePosition.y - halfDim + 1, terrainChunks[i + halfDim, row]);
                }
            }
        }

        //Reload the chunks after generating the missing ones
        //ReloadChunkArrayFromStorage();
    }
    private void InstantiateChunks(TERRAIN.ETerrain[,] _startTerrain)
    {
        terrainChunks       = new TerrainChunk[terrainDimension, terrainDimension];
        terrainChunkStorage = new MeshList <TerrainChunk>();
        int halfDim = GetTerrainDimCenter();

        for (int x = 0; x < terrainDimension; x++)
        {
            for (int z = 0; z < terrainDimension; z++)
            {
                terrainChunks[x, z] = new TerrainChunk(_startTerrain[x, z],
                                                       new Vector3(planetData.GetTerrainSize().x *(x - halfDim), 0, planetData.GetTerrainSize().y *(z - halfDim)) + currentCenter,
                                                       planetData.GetTerrainSize(),
                                                       this);
            }
        }



        terrainChunkStorage.SetCenter(terrainChunks[halfDim, halfDim]);
        //first do the middle line
        for (int x = 0; x < halfDim; x++)
        {
            terrainChunkStorage.AddLeft(-x, 0, terrainChunks[halfDim - x - 1, halfDim]);
            terrainChunkStorage.AddRight(x, 0, terrainChunks[halfDim + x + 1, halfDim]);
        }

        //the in parallel always do the line above and below in one set
        for (int y = 0; y < halfDim; y++)
        {
            terrainChunkStorage.AddAbove(0, y, terrainChunks[halfDim, halfDim + y + 1]);
            terrainChunkStorage.AddBelow(0, -y, terrainChunks[halfDim, halfDim - y - 1]);

            for (int x = 0; x < halfDim; x++)
            {
                terrainChunkStorage.AddLeft(-x, y + 1, terrainChunks[halfDim - x - 1, halfDim + y + 1]);
                terrainChunkStorage.AddRight(x, y + 1, terrainChunks[halfDim + x + 1, halfDim + y + 1]);
            }
            for (int x = 0; x < halfDim; x++)
            {
                terrainChunkStorage.AddLeft(-x, -(y + 1), terrainChunks[halfDim - x - 1, halfDim - y - 1]);
                terrainChunkStorage.AddRight(x, -(y + 1), terrainChunks[halfDim + x + 1, halfDim - y - 1]);
            }
        }

        ReloadChunkArrayFromStorage();

        currentStoragePosition = new Vector2Int(0, 0);
    }