private void CreateWorldChunkPrefabs() { m_ChunkGameObjects = new Transform[WorldData.ChunksWide, WorldData.ChunksHigh, WorldData.ChunksDeep]; for (int x = 0; x < WorldData.ChunksWide; x++) { for (int y = 0; y < WorldData.ChunksHigh; y++) { for (int z = 0; z < WorldData.ChunksDeep; z++) { Chunk chunk = WorldData.Chunks[x, y, z]; Vector3 chunkGameObjectPosition = new Vector3(chunk.X * WorldData.ChunkBlockWidth + WorldData.GlobalXOffset, 0, chunk.Y * WorldData.ChunkBlockHeight + WorldData.GlobalZOffset); Transform chunkGameObject = Instantiate(Chunk_Prefab, chunkGameObjectPosition, Quaternion.identity) as Transform; chunkGameObject.parent = m_ChunksParent; chunkGameObject.name = chunk.ToString(); m_ChunkGameObjects[x, y, z] = chunkGameObject; ChunkGameObject chunkGameObjectScript = chunkGameObject.GetComponent <ChunkGameObject>(); chunkGameObjectScript.Texture = WorldTextureAtlas; } } } }
private void CreateFinishedChunk() { while (WorldData.FinishedChunks.Count > 0) { if (!m_ReadyToActivatePlayer) { m_ReadyToActivatePlayer = true; Player.gameObject.SetActive(true); } Chunk chunk = WorldData.GetFinishedChunk(); if (chunk == null) { return; } ChunkGameObject chunkGameObjectScript = m_ChunkGameObjects[chunk.X, chunk.Y, chunk.Z].GetComponent <ChunkGameObject>(); chunkGameObjectScript.CreateFromChunk(chunk); if (!m_ProcessAllChunksAtOnce) { return; } } }