/// <summary> /// 获取输出资源信息。 /// </summary> /// <returns></returns> public static List <BuildResourcesInfo> LoadBuildResourcesInfo() { var path = string.Concat(GetFolderPath("ResourceDef"), "\\ForBuild.xml"); //LogDebug(path); var xml = XMLParser.LoadXML(Utils.LoadFile(path)); if (xml == null) { //EditorUtility.DisplayDialog("Error", "Load Build Resources Info Error.", "ok"); return(null); } var result = new List <BuildResourcesInfo>(); foreach (SecurityElement item in xml.Children) { var info = new BuildResourcesInfo(); info.check = true; info.name = (item.Children[0] as SecurityElement).Text; info.type = (item.Children[1] as SecurityElement).Text; info.copyOrder = (item.Children[2] as SecurityElement).Text; info.isPopInBuild = bool.Parse((item.Children[3] as SecurityElement).Text); info.extentions = (item.Children[4] as SecurityElement).Text.Split(' '); var folders = item.Children[5] as SecurityElement; info.folders = new List <BuildResourcesSubInfo>(); foreach (SecurityElement folder in folders.Children) { var sub = new BuildResourcesSubInfo() { path = (folder.Children[0] as SecurityElement).Text, deep = bool.Parse((folder.Children[1] as SecurityElement).Text), check = true }; info.folders.Add(sub); } result.Add(info); } return(result); }
/// <summary> /// 获取输出资源信息。 /// </summary> /// <returns></returns> public static List<BuildResourcesInfo> LoadBuildResourcesInfo() { var path = string.Concat(GetFolderPath("ResourceDef"), "\\ForBuild.xml"); //LogDebug(path); var xml = XMLParser.LoadXML(Utils.LoadFile(path)); if (xml == null) { //EditorUtility.DisplayDialog("Error", "Load Build Resources Info Error.", "ok"); return null; } var result = new List<BuildResourcesInfo>(); foreach (SecurityElement item in xml.Children) { var info = new BuildResourcesInfo(); info.check = true; info.name = (item.Children[0] as SecurityElement).Text; info.type = (item.Children[1] as SecurityElement).Text; info.copyOrder = (item.Children[2] as SecurityElement).Text; info.isPopInBuild = bool.Parse((item.Children[3] as SecurityElement).Text); info.extentions = (item.Children[4] as SecurityElement).Text.Split(' '); var folders = item.Children[5] as SecurityElement; info.folders = new List<BuildResourcesSubInfo>(); foreach (SecurityElement folder in folders.Children) { var sub = new BuildResourcesSubInfo() { path = (folder.Children[0] as SecurityElement).Text, deep = bool.Parse((folder.Children[1] as SecurityElement).Text), check = true }; info.folders.Add(sub); } result.Add(info); } return result; }
//获得需要被导出资源,返回值第一个是绝对路径,第二个是相对路径 public static Dictionary<string, string> GetAssetDictByPath(BuildResourcesInfo item, string rootdir) { var newVersion = GetNewVersionByTempClientPath(rootdir + "/Export"); string ExportDir = rootdir + "/Export/" + newVersion + "/ExportedFiles"; Dictionary<string, string> dict = new Dictionary<string, string>(); foreach (var folder in item.folders) { var path = ExportDir + "/" + folder.path; //ExportScenesManager.LogDebug("获取原路径下文件:" + path); if (!Directory.Exists(path)) { ExportScenesManager.LogError("源文件夹不存在:" + path); continue; } string[] uFiles = Directory.GetFiles(path, "*.u", folder.deep ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); string[] xmlFiles = Directory.GetFiles(path, "*.xml", folder.deep ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); List<string> files = new List<string>(); files.AddRange(uFiles); files.AddRange(xmlFiles); foreach (var file in files) { string filePath = file.Replace("\\", "/"); dict.Add(filePath, folder.path); } } return dict; }
private void CopyAssetBundle(BuildResourcesInfo item) { //if (String.IsNullOrEmpty(item.copyOrder)) //{ PackManually(item.name, new VersionCodeInfo(m_newVersion)); //} //else //{ // var exportPath = ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath); // var versionFolder = Path.Combine(exportPath, m_newVersion); // var uiRoot = Path.Combine(versionFolder, item.name) + "\\" + ExportScenesManager.SubMogoResources; // LogDebug(uiRoot); // var red = Path.Combine(ExportScenesManager.GetFolderPath("ResourceDef"), item.copyOrder); // var files = Utils.LoadFile(red); // var fs = files.Split('\n'); // var firstList = new List<DirectoryInfo>(); // for (int i = 0; i < fs.Length - 1; i++) // { // var fullName = uiRoot + "\\" + fs[i].Trim(); // var dir = new DirectoryInfo(fullName); // if (dir.Exists) // firstList.Add(dir); // } // LogDebug("firstList: " + firstList.Count); // var left = new List<DirectoryInfo>(); // var af = Directory.GetDirectories(uiRoot); // foreach (var a in af) // { // var fullName = a.Replace("/", "\\"); // var dir = new DirectoryInfo(fullName); // if (firstList.Contains(dir)) // continue; // else // left.Add(dir); // } // LogDebug("left: " + left.Count); // firstList.AddRange(left); // PackManually(firstList, item.name, new VersionCodeInfo(m_newVersion)); //} }
public static IEnumerable<string> GetAssetList(BuildResourcesInfo item) { List<string> list = new List<string>(); foreach (var folder in item.folders) { var root = Application.dataPath + "/" + folder.path; ExportScenesManager.LogDebug("root: " + root); foreach (var extention in item.extentions) { var sp = "*" + extention; ExportScenesManager.LogDebug("sp: " + sp); list.AddRange(Directory.GetFiles(root, sp, folder.deep ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)); } } var newList = from fileName in list select fileName.Replace("\\", "/").ReplaceFirst(Application.dataPath, "Assets"); ExportScenesManager.LogDebug("list.Count: " + list.Count); return newList; }
private void BuildAssetVersion(BuildResourcesInfo item, string rootPath) { BundleExporter.BuildAssetVersion(GetAssetList(item).ToArray(), rootPath); }
private static void BuildAssetBundleMainAsset(BuildResourcesInfo item, string exportRootPath, bool isMerge = false) { BundleExporter.BuildBundleWithRoot(GetAssetList(item).ToArray(), exportRootPath, isMerge); }
private void BuildAssetBundleInfo(BuildResourcesInfo item) { List<string> list = new List<string>(); foreach (var folder in item.folders) { var root = Application.dataPath + "/" + folder.path; LogDebug(root); foreach (var extention in item.extentions) { var sp = "*" + extention; LogDebug(sp); list.AddRange(Directory.GetFiles(root, sp, folder.deep ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)); } } LogDebug(list.Count); BuildResourceInfoManually(new VersionCodeInfo(m_currentVersion), new VersionCodeInfo(m_newVersion), item.name, item.type, list, item.isPopInBuild, item.extentions); }