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); }
public static void Test() { var config = "/Users/admin/Desktop/tar_config/configs/config_22007_01_05.txt"; var blockConfig = PBBlockConfigManager.LoadBlockInfosWithoutAnim(config); PPPrefabInfo targetPrefab = null; PPBlockInfo targetBlock = null; foreach (PBPartInfo partInfo in blockConfig.BlockInfos) { if (partInfo.BlockInfo.IsSticker && partInfo.PrefabName.Equals("sticker_prefab_ppbbbmhmf_09_common")) { targetBlock = partInfo.BlockInfo; break; } } foreach (var t in blockConfig.PrefabInfos) { if (t.IsSticker && t.Name.Equals("sticker_prefab_ppbbbmhmf_09_common")) { targetPrefab = t; break; } } if (targetPrefab == null || targetBlock == null) { Debug.LogError("空"); return; } if (!string.IsNullOrEmpty(targetPrefab.Material)) { targetPrefab.MaterialInfos.Add(PBDataBaseManager.Instance.GetMatInfoByName(targetPrefab.Material)); } targetPrefab.Texs.ForEach(t => { t.skin_url = texPrefix + t.Texture + ".png"; t.bin_url = texModelPrefix + t.Model + "/buffer.bin"; t.gltf_url = texModelPrefix + t.Model + "/" + t.Model + ".gltf"; }); var renderinfo = new RenderInfo(); renderinfo.scale = 2; renderinfo.items = new[] { new RenderItem() { name = targetPrefab.Name, model = targetPrefab.Model, material = targetPrefab.Material, matinfos = targetPrefab.MaterialInfos, bin_url = stickerModelPrefix + targetPrefab.Model + "/buffer.bin", gltf_url = stickerModelPrefix + targetPrefab.Model + "/" + targetPrefab.Model + ".gltf", skins = !string.IsNullOrEmpty(targetPrefab.Texture)? new[] { new SkinInfo() { skin_name = targetPrefab.Texture, skin_url = texPrefix + targetPrefab.Texture + ".png", } }:new SkinInfo [0], texs = targetPrefab.Texs } }; File.WriteAllText(Application.dataPath + "/test111.json", JsonUtility.ToJson(renderinfo, true)); Debug.Log("===>>完成"); }
private static void GetSkuMainConfig_BlockNum_AnimSteps() { var content = File.ReadAllText(PATH_CSV_SKU); SkuConfig skuConfig = SkuConfig.LoadConfig(content) as SkuConfig; content = File.ReadAllText(PATH_CSV_SKUCAR); SkuCarConfig skuCarConfig = SkuCarConfig.LoadConfig(content) as SkuCarConfig; List <SkuMainConfig_BlockNum_AnimSteps_Data> dataList = new List <SkuMainConfig_BlockNum_AnimSteps_Data>(); foreach (SkuItem sku in skuConfig.Items) { SkuMainConfig_BlockNum_AnimSteps_Data data = new SkuMainConfig_BlockNum_AnimSteps_Data(); data.SkuID = sku.SkuId; if (sku.SkuId == 1002) { data.Config = "config_01002_sdlr_01_mk"; } else if (sku.SkuId == 1003) { data.Config = "config_01003_01_Xmas_set"; } else { SkuCarItem mainCar = skuCarConfig.Items.Find(carItem => carItem.SkuType == sku.ConfigFile && carItem.ConfigFile.EndsWith("01")); if (mainCar == null) { Debug.LogFormat("<color=yellow> sku {0} 找不到主搭建config!</color>", sku.SkuId); continue; } data.Config = mainCar.ConfigFile; } PPBlockConfigInfo configInfo = PBBlockConfigManager.LoadBlockInfos(data.Config + ".txt"); if (configInfo == null) { Debug.LogFormat("<color=red> {0} 不存在! </color>", data.Config); continue; } data.BlockNum = configInfo.BlockNum; data.AnimSteps = configInfo.KeyfameInfos.Count - 1; dataList.Add(data); } string exportPath = Application.dataPath.Substring(0, Application.dataPath.IndexOf("Assets")) + "sku统计.xlsx"; using (ExcelPackage package = new ExcelPackage(new FileInfo(exportPath))) { ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("info"); worksheet.Cells[1, 1].Value = "SkuID"; worksheet.Cells[1, 2].Value = "Config"; worksheet.Cells[1, 3].Value = "零件数"; worksheet.Cells[1, 4].Value = "步骤数"; int rowIndex = 2; foreach (SkuMainConfig_BlockNum_AnimSteps_Data data in dataList) { worksheet.Cells[rowIndex, 1].Value = data.SkuID; worksheet.Cells[rowIndex, 2].Value = data.Config; worksheet.Cells[rowIndex, 3].Value = data.BlockNum; worksheet.Cells[rowIndex, 4].Value = data.AnimSteps; rowIndex++; } package.Save(); } }