private void GenerateChunks <T>(ref ChunkPool <T> chunkPool) where T : Chunk { chunkPool.ResetRows(); chunkPool.dictionary.Clear(); for (int x = 0; x < chunkPool.poolWidth; x++) { for (int y = 0; y < chunkPool.poolHeight; y++) { Int2 camPosition = RoundToChunkPos(new Int2(cam.transform.position), chunkPool.chunkSize); Int2 pos = new Int2((x - chunkPool.poolWidth / 2) * chunkPool.chunkSize, (y - chunkPool.poolHeight / 2) * chunkPool.chunkSize); pos += camPosition; chunkPool.dictionary.Add(pos, chunkPool.chunkArray[x, y]); chunkPool.chunkArray[x, y].transform.position = new Vector2(pos.x, pos.y); chunkPool.chunkArray[x, y].Position = pos; } } }