/// 普通资源,非bundle,直接拷贝 二进制文件组 static void BuildNormalResource(BinaryPackInfo ResInfo, string ifsBuildDir) { if (ResInfo == null) { return; } for (int j = 0; j < ResInfo.Resources.Count; j++) { ResInfo res = ResInfo.Resources[j]; string resourceFullPathInResources = res.Path + res.Ext; string resourceSrcFullPath = JW.Res.FileUtil.CombinePaths(Application.dataPath, "Resources", resourceFullPathInResources); string resourceDstFullDirectory = JW.Res.FileUtil.CombinePaths( ifsBuildDir, "", JW.Res.FileUtil.GetFullDirectory(resourceFullPathInResources)); if (!JW.Res.FileUtil.IsDirectoryExist(resourceDstFullDirectory)) { JW.Res.FileUtil.CreateDirectory(resourceDstFullDirectory); } string resourceDstFullPath = JW.Res.FileUtil.CombinePath(resourceDstFullDirectory, JW.Res.FileUtil.GetFullName(resourceFullPathInResources)); if (JW.Res.FileUtil.IsFileExist(resourceSrcFullPath)) { JW.Res.FileUtil.CopyFile(resourceSrcFullPath, resourceDstFullPath); } else { Terminate("CopyBinaryError:" + "File " + resourceFullPathInResources + " is not exist!"); } } }
/// 解析二进制 BinaryGroup 组 bool ParseBinaryGroup(XmlNode node, BuildTarget target, bool allowEmpty) { //检查Platform属性 if (node.Attributes["Platform"] != null) { string platform = node.Attributes["Platform"].Value; //platform不匹配,不打包 if (!string.Equals(platform, GetPlatformStr(target), StringComparison.OrdinalIgnoreCase)) { JW.Common.Log.LogE("Platform not match, ignore."); return(false); } } BinaryPackInfo info = new BinaryPackInfo(); info.Path = node.Attributes["DstPath"].Value; //包含的二进制 for (int i = 0; i < node.ChildNodes.Count; ++i) { if (node.ChildNodes[i].Name == "Binary") { XmlNode nd = node.ChildNodes[i]; string srcPathInResources = nd.Attributes["SrcPath"].Value; string srcFullPath = JW.Res.FileUtil.CombinePath(JW.Res.FileUtil.CombinePath(Application.dataPath, "Resources"), srcPathInResources); SearchOption option = SearchOption.TopDirectoryOnly; if (nd.Attributes["recursive"] != null && nd.Attributes["recursive"].Value.ToLower() == "true") { option = SearchOption.AllDirectories; } string[] files = Directory.GetFiles(JW.Res.FileUtil.GetFullDirectory(srcFullPath), JW.Res.FileUtil.GetFullName(srcFullPath), option).Where(name => !name.EndsWith(".meta", true, null)).ToArray(); if (files == null || files.Length <= 0) { continue; } for (int j = 0; j < files.Length; j++) { string filePathInResources = GetPathInResources(files[j]); ResInfo ResInfo = new ResInfo(); ResInfo.Path = JW.Res.FileUtil.EraseExtension(filePathInResources); ResInfo.Ext = JW.Res.FileUtil.GetExtension(filePathInResources); if (nd.Attributes["clear"] != null && nd.Attributes["clear"].Value.Equals("true", StringComparison.OrdinalIgnoreCase)) { ResInfo.Keep = false; ResInfo.RelativePath = JW.Res.FileUtil.CombinePath("Assets/Resources", filePathInResources); } else { ResInfo.Keep = true; ResInfo.RelativePath = JW.Res.FileUtil.CombinePath("Assets/Resources", filePathInResources); } info.Add(ref ResInfo); } } } if (info.Resources.Count == 0) { JW.Common.Log.LogE("No binary file for " + info.Path); return(false); } _config.AddPackInfo(info); return(true); }