void CleanMap(BlockMap blockMap){ ChunkSet[] map = blockMap.map; //Strip empty blocks and such for(int i = 0; i < map.Length; i++){ if(map[i] != null){ for(int c = 0; c < map[i].chunkSet.Length; c++){ MapChunk m = map[i].chunkSet[c].chunk; //Delete empty chunks if(m.chunkPieces == null || m.chunkPieces.Length <= 0){ if(selectedStrippingLevel == StrippingLevel.Strip_All){ Editor.DestroyImmediate(m.gameObject); } else{ if(m.GetComponent<Renderer>() != null){ Editor.DestroyImmediate(m.GetComponent<Renderer>()); } MeshFilter mf = m.GetComponent<MeshFilter>(); if(mf != null){ Editor.DestroyImmediate(mf); } if(m.GetComponent<Collider>() != null){ Editor.DestroyImmediate(m.GetComponent<Collider>()); } } continue; } if(m.chunkPieces != null){ for(int j = 0; j < m.chunkPieces.Length; j++){ if(m.chunkPieces[j].isNullBlock){ Block mb = m.chunkPieces[j]; //Debug.Log("Hiding " + mb.x + "," + mb.y); mb.Hide(); //Delete things below it on the hierarchy for(int d = 0; d < mb.transform.childCount; d++){ GameObject o = mb.transform.GetChild(d).gameObject; Editor.DestroyImmediate(o); } if(selectedStrippingLevel == StrippingLevel.Working_Blocks_Only){ m.chunkPieces[j].GetComponent<Collider>().isTrigger = true; } else{ Editor.DestroyImmediate(m.chunkPieces[j].gameObject); continue; } continue; } else if(!m.chunkPieces[j].retainCollider){ m.chunkPieces[j].GetComponent<Collider>().isTrigger = true; } } } } } } if(selectedStrippingLevel == StrippingLevel.Strip_All){ OrientedBlock[] blocks = blockMap.GetComponentsInChildren<OrientedBlock>(); MapChunk[] chunks = blockMap.GetComponentsInChildren<MapChunk>(); for(int i = 0; i < blocks.Length; i++){ Editor.DestroyImmediate(blocks[i]); } for(int i = 0; i < chunks.Length; i++){ Editor.DestroyImmediate(chunks[i]); } Editor.DestroyImmediate(blockMap); } }