private static bool CreateBuildingThumbConfigFile(string filePath, List <ResItem> thumbInfoItems, string outputDir, bool isOnline) { var fileName = Path.GetFileNameWithoutExtension(filePath); if (EXCLUDE_BUILDINGS.Contains(fileName)) { return(false); } #if BLOCK_EDITOR PPBlockConfigInfo configInfo = PBBlockConfigManager.LoadBlockInfosWithoutAnim(filePath); #elif BLOCK_MODEL var path = "./" + BlockServerUtil.GetBuildAnimPath(isOnline) + "/" + fileName + ".txt"; var configText = File.Exists(path) ? File.ReadAllText(path, Encoding.UTF8) : string.Empty; PPBlockConfigInfo configInfo = PBBlockConfigManager.LoadBlockInfosWithoutAnim(fileName + ".txt", configText); if (configInfo == null) { Debug.LogError(path + ">>>" + (File.Exists(path) ? "搭建文件内容有问题!" : "搭建文件不存在!")); return(false); } #endif var buildingThumbs = new ResConfig { resversion = "100", items = new List <ResItem>() }; foreach (var item in configInfo.BlockInfos) { var equal = item.BlockInfo.IsStamp ? item.BlockInfo.GetStampThumb : item.ThumbName; if (thumbInfoItems.Any(s => s.name.Equals(equal))) { var t = thumbInfoItems.FirstOrDefault(s => s.name.Equals(equal)); buildingThumbs.items.Add(t); } else { if (item.ThumbName != "diban") { if (!mThumbErrors.Contains(fileName)) { mThumbErrors.Add(fileName); } Debug.LogError(item.ThumbName + ">>>>*找不到缩率图******" + equal + ".png"); } } } var config = JsonUtility.ToJson(buildingThumbs, true); File.WriteAllText(Path.Combine(outputDir, fileName), config); return(true); }
private static bool CreateBuildingModeResFile(string filePath, List <ResItem> modelAbInfoItems, List <ResItem> textureInfoItems, List <PEMaterialUtl.MaterialInfo> materialInfos, string outputDir, bool isOnline) { var fileName = Path.GetFileNameWithoutExtension(filePath); if (ResPublisher.EXCLUDE_BUILDINGS.Contains(fileName)) { return(false); } #if BLOCK_EDITOR PPBlockConfigInfo configInfo = PBBlockConfigManager.LoadBlockInfosWithoutAnim(filePath); #elif BLOCK_MODEL // var path = "./" + BlockServerUtil.GetBuildAnimPath(isOnline) + "/" + fileName + ".txt"; var path = "./" + BlockServerUtil.GetBuildAnimPath(isOnline) + "/" + fileName + ".txt"; //here change later var configText = File.Exists(path) ? File.ReadAllText(path, Encoding.UTF8) : string.Empty; PPBlockConfigInfo configInfo = PBBlockConfigManager.LoadBlockInfosWithoutAnim(fileName, configText); if (configInfo == null) { Debug.LogError(path + ">>>" + (File.Exists(path) ? "搭建文件内容有问题!" : "搭建文件不存在!")); return(false); } #endif var buildingModelResConfig = new ResConfig { resversion = "100", items = new List <ResItem>() }; foreach (var item in configInfo.BlockInfos) { //地板特殊处理,配置表里面没有地板 if (item.PrefabName == "diban") { AddResItem("diban", "Assets/blockres/lowpolygon/category_1/block_fbxs/diban", buildingModelResConfig.items, modelAbInfoItems); continue; } if (item.PrefabName.StartsWith("sticker")) { CreateStickerItem(item.PrefabName, buildingModelResConfig.items, modelAbInfoItems, textureInfoItems); continue; } var blockData = PBDataBaseManager.Instance.GetDataWithPrefabName(item.PrefabName) as BlockData; Category category = (Category)Enum.Parse((typeof(Category)), blockData.category); string fbxDir = (BlockPath.Fbx(category, PolygonType.LOW)); string matDir = (BlockPath.Material(category, PolygonType.LOW)); AddResItem(blockData.model, (Path.Combine(fbxDir, blockData.model)), buildingModelResConfig.items, modelAbInfoItems); CreateMaterials(blockData.material, matDir, buildingModelResConfig.items, modelAbInfoItems, textureInfoItems, materialInfos); CreateTextures(item, buildingModelResConfig.items, modelAbInfoItems, textureInfoItems); } var config = JsonUtility.ToJson(buildingModelResConfig, true); File.WriteAllText(Path.Combine(outputDir, fileName), config); return(true); }