public static bool AddOrUpdateResourceConfigTree(PBData_ResourceConfigInfo info, ref PBData_ResourceConfigTree rConfigTree) { if (rConfigTree == null || info == null) { return(false); } if (rConfigTree.config_list == null) { rConfigTree.config_list = new List <PBData_ResourceConfigInfo>(); } bool bUpdate = false; Int32 nSize = rConfigTree.config_list.Count; for (Int32 i = 0; i < nSize; ++i) { PBData_ResourceConfigInfo tmpInfo = rConfigTree.config_list[i]; if (tmpInfo == null) { continue; } if (tmpInfo.key == info.key) { rConfigTree.config_list[i] = info; bUpdate = true; } } if (bUpdate == false) { rConfigTree.config_list.Add(info); } return(true); }
public static PBData_ResourceConfigInfo GetConfigTreeLeaf(string strKey, PBData_ResourceConfigTree rConfigTree) { if (rConfigTree == null) { return(null); } if (rConfigTree.config_list == null) { return(null); } Int32 nSize = rConfigTree.config_list.Count; for (Int32 i = 0; i < nSize; ++i) { PBData_ResourceConfigInfo tmpInfo = rConfigTree.config_list[i]; if (tmpInfo == null) { continue; } if (tmpInfo.key == strKey) { return(tmpInfo); } } return(null); }
static bool BuildTextEditor() { // 获取BuildAll.config if (sBuildAllConfig == null) { UnityEngine.Debug.LogError("Load BuildAll.config Failed"); return(false); } // 获取配置树, 如果没有则增加 PBData_ResourceConfigTree configTree = GetBuildConfigTree(TResourceBuildType.enEditorBuild); if (configTree == null) { UnityEngine.Debug.LogError("Get Config Tree Failed"); return(false); } PBData_ResourceConfigInfo textConfigInfo = ResourceConfigTree.GetConfigTreeLeaf(PackageSetting.sConfigTreeTextKey, configTree); if (textConfigInfo == null) { textConfigInfo = new PBData_ResourceConfigInfo(); textConfigInfo.key = PackageSetting.sConfigTreeTextKey; textConfigInfo.path = GetConfigTreeLeafPath(TResourceBuildType.enEditorBuild, PackageSetting.sConfigTreeTextKey); ResourceConfigTree.AddOrUpdateResourceConfigTree(textConfigInfo, ref configTree); } // todo build Text PBData_EditorResourceInfoList resourceInfoList = new PBData_EditorResourceInfoList(); GameUtil.SaveToXmlFile(resourceInfoList, textConfigInfo.path); SaveConfigTree(TResourceBuildType.enEditorBuild, configTree); return(true); }
protected string GetFilePathEditorMode(string strKey) { string strPath = string.Empty; if (strKey == PackageSetting.sConfigTreeKey) { strPath = GetConfigTreePath(); return(strPath); } PBData_ResourceConfigInfo pbInfo = null; if (strKey == PackageSetting.sConfigTreeObjectKey || strKey == PackageSetting.sConfigTreeUIKey || strKey == PackageSetting.sConfigTreeParticleKey || strKey == PackageSetting.sConfigTreeAudioKey || strKey == PackageSetting.sConfigTreeTextKey) { if (Data_ConfigTree.TryGetConfigInfo(strKey, out pbInfo) == true && pbInfo != null) { strPath = pbInfo.path; } return(strPath); } if (Data_EditorTextList.TryGetFilePath(strKey, out strPath) == false) { return(string.Empty); } return(strPath); }
static bool BuildObjectEditor() { // 获取BuildAll.config if (sBuildAllConfig == null) { UnityEngine.Debug.LogError("Load BuildAll.config Failed"); return(false); } // 获取配置树, 如果没有则增加 PBData_ResourceConfigTree configTree = GetBuildConfigTree(TResourceBuildType.enEditorBuild); if (configTree == null) { UnityEngine.Debug.LogError("Get Config Tree Failed"); return(false); } PBData_ResourceConfigInfo objectConfigInfo = ResourceConfigTree.GetConfigTreeLeaf(PackageSetting.sConfigTreeObjectKey, configTree); if (objectConfigInfo == null) { objectConfigInfo = new PBData_ResourceConfigInfo(); objectConfigInfo.key = PackageSetting.sConfigTreeObjectKey; objectConfigInfo.path = GetConfigTreeLeafPath(TResourceBuildType.enEditorBuild, PackageSetting.sConfigTreeObjectKey); ResourceConfigTree.AddOrUpdateResourceConfigTree(objectConfigInfo, ref configTree); } // 读取Object资源已有配置 PBData_EditorResourceInfoList resourceInfoList = null; string strXML = GameEditorUtil.TextResourceLoadAtPath(objectConfigInfo.path); if (string.IsNullOrEmpty(strXML) == false) { resourceInfoList = GameUtil.ReadFromXmlString <PBData_EditorResourceInfoList>(strXML); } // 单个打包还是所有打包 GameObject selectObj = Selection.activeGameObject; bool bBuildRet = false; if (selectObj == null) { bBuildRet = ObjectResourceBuilder.BuildEditorObject(sBuildAllConfig.ObjectList, ref resourceInfoList); } else { bBuildRet = ObjectResourceBuilder.BuildEditorObject(selectObj, ref resourceInfoList); } if (bBuildRet == false) { UnityEngine.Debug.LogError("Build Object Failed"); return(false); } GameUtil.SaveToXmlFile(resourceInfoList, objectConfigInfo.path); SaveConfigTree(TResourceBuildType.enEditorBuild, configTree); return(bBuildRet); }