void CreateMeshAssets(Transform cave, string path) { string floorFolder = IOHelpers.CreateFolder(path, FLOOR_FOLDER); string ceilingFolder = IOHelpers.CreateFolder(path, CEILING_FOLDER); string wallFolder = IOHelpers.CreateFolder(path, WALL_FOLDER); foreach (Transform sector in cave.transform) { foreach (Transform component in sector) { if (Sector.IsFloor(component)) { CreateMeshAsset(component, floorFolder); } else if (Sector.IsCeiling(component)) { CreateMeshAsset(component, ceilingFolder); } else if (Sector.IsWall(component)) { CreateMeshAsset(component, wallFolder); } } } foreach (string folder in new[] { floorFolder, wallFolder, ceilingFolder }) { if (IOHelpers.IsFolderEmpty(folder)) { AssetDatabase.DeleteAsset(folder); } } }
protected override void SaveAdditionalAssets(GameObject cave, string path) { string ceilingFolder = IOHelpers.CreateFolder(path, CEILING_FOLDER); string floorFolder = IOHelpers.CreateFolder(path, FLOOR_FOLDER); string wallFolder = IOHelpers.CreateFolder(path, WALL_FOLDER); foreach (Transform sector in cave.transform) { foreach (Transform component in sector) { if (Sector.IsFloor(component)) { CreateMeshAsset(component, floorFolder); } else if (Sector.IsCeiling(component)) { CreateMeshAsset(component, ceilingFolder); } else if (Sector.IsWall(component)) { CreateMeshAsset(component, wallFolder); } } } }
protected override void SaveAdditionalAssets(GameObject cave, string path) { string floorFolder = IOHelpers.CreateFolder(path, FLOOR_FOLDER); foreach (Transform sector in cave.transform) { foreach (Transform component in sector) { if (Sector.IsFloor(component)) { CreateMeshAsset(component, floorFolder); } } } }
void CreatePrefab(GameObject cave) { string rootFolderPath = IOHelpers.RequireFolder(ROOT_FOLDER); string caveFolderPath = IOHelpers.RequireFolder(rootFolderPath, PREFAB_FOLDER); string prefabFolderPath = IOHelpers.CreateFolder(caveFolderPath, CAVE_FOLDER); try { CreateMeshAssets(cave.transform, prefabFolderPath); string path = IOHelpers.CombinePath(prefabFolderPath, PREFAB_NAME); PrefabUtility.CreatePrefab(path, cave); } catch (InvalidOperationException) { AssetDatabase.DeleteAsset(prefabFolderPath); throw; } }