public void CreateSimpleChunk(int x, int y, int z) { WorldPos worldPos = new WorldPos(x, y, z); //Instantiate the chunk at the coordinates using the chunk prefab GameObject newSimpleChunkObject = Instantiate( simpleChunkPrefab, new Vector3(x, y, z), Quaternion.Euler(Vector3.zero) ) as GameObject; SimpleChunk newSimpleChunk = newSimpleChunkObject.GetComponent <SimpleChunk>(); newSimpleChunk.pos = worldPos; newSimpleChunk.simpleWorld = this; //Add it to the chunks dictionary with the position as the key simpleChunks.Add(worldPos, newSimpleChunk); var terrainGen = new TerrainGen(); newSimpleChunk = terrainGen.SimpleChunkGen(newSimpleChunk); if (newSimpleChunk.simpleChunkType == SimpleChunkType.Air) { newSimpleChunk.gameObject.SetActive(false); return; } newSimpleChunkObject.GetComponent <Renderer>().material.mainTexture = textureDict.textDict[newSimpleChunk.simpleChunkType]; }