示例#1
0
        public Chunk(ChunkObject terrain, Transform parent, bool visible, ChunkMesh meshData)
        {
            this.meshData = meshData;

            CreateChunkObject(terrain, parent);
            DrawMesh();
            UpdateMeshCollider();
            SetVisible(visible);
            meshData.ConnectChunk(this);
        }
        public static void CreateChunks(ChunkObject terrain, Transform parent, bool visible)
        {
            if (WorldMesh.chunkMeshMap == null)
            {
                return;
            }

            WorldMesh.ConfirmChanges(false);
            ClearChunkMap();

            chunkMap = new Chunk[chunkXCount, chunkYCount];
            for (int x = 0; x < chunkXCount; x++)
            {
                for (int y = 0; y < chunkYCount; y++)
                {
                    chunkMap[x, y] = new Chunk(terrain, parent, visible, WorldMesh.chunkMeshMap[x, y]);
                }
            }
        }
示例#3
0
 private void CreateChunkObject(ChunkObject terrain, Transform parent)
 {
     chunkObject      = Object.Instantiate(terrain, parent);
     chunkObject.name = "Chunk" + meshData.chunkX + " " + meshData.chunkY;
     meshFilter       = chunkObject.GetComponent <MeshFilter>();
 }