Esempio n. 1
0
        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);
        }
    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 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);
        }