void SaveItem() { //GameObject setobj = null;//选中的对象 //bool bUseHashName = true;//是否使用hash作为资源文件名 //string exportResult = null;//导出结果 //string exportPath = null;//导出路径 //bool bUseHashTreeName = false;//是否使用hash作为导出节点名 //string exportNodeName = "";//导出节点名称 nodeParser.nodeParser np = new nodeParser.nodeParser(); np.SaveNode(this.setobj);//先强制使用HashName if (System.IO.Directory.Exists(exportPath) == false) { System.IO.Directory.CreateDirectory(exportPath); } string respath = System.IO.Path.Combine(exportPath, "resources"); if (System.IO.Directory.Exists(respath) == false) { System.IO.Directory.CreateDirectory(respath); } MyJson.JsonNode_Array indexfile = new MyJson.JsonNode_Array(); foreach (var f in np.bufs) { //写入文件 { var file = System.IO.Path.Combine(respath, f.Key); System.IO.File.WriteAllBytes(file, f.Value); } //记录索引 MyJson.JsonNode_Object indexitem = new MyJson.JsonNode_Object(); indexitem["Name"] = new MyJson.JsonNode_ValueString("resources/" + f.Key); indexitem["Length"] = new MyJson.JsonNode_ValueNumber(f.Value.Length); indexfile.Add(indexitem); } indexfile.Sort((a, b) => { return(string.Compare(a.asDict()["Name"].AsString(), b.asDict()["Name"].AsString())); }); {//保存索引文件 byte[] indexcode = System.Text.Encoding.UTF8.GetBytes(indexfile.ToString()); exportResult = exportNodeName; if (bUseHashTreeName) { exportResult = ResLibTool.ComputeHashString(indexcode); } string outfile = System.IO.Path.Combine(exportPath, exportResult + ".indexlist.txt"); System.IO.File.WriteAllBytes(outfile, indexcode); } }
void SaveItem() { //GameObject setobj = null;//选中的对象 //bool bUseHashName = true;//是否使用hash作为资源文件名 //string exportResult = null;//导出结果 //string exportPath = null;//导出路径 //bool bUseHashTreeName = false;//是否使用hash作为导出节点名 //string exportNodeName = "";//导出节点名称 nodeParser.nodeParser np = new nodeParser.nodeParser(); np.SaveNode(this.setobj);//先强制使用HashName if (System.IO.Directory.Exists(exportPath) == false) System.IO.Directory.CreateDirectory(exportPath); string respath = System.IO.Path.Combine(exportPath, "resources"); if (System.IO.Directory.Exists(respath) == false) System.IO.Directory.CreateDirectory(respath); MyJson.JsonNode_Array indexfile = new MyJson.JsonNode_Array(); foreach (var f in np.bufs) { //写入文件 { var file = System.IO.Path.Combine(respath, f.Key); System.IO.File.WriteAllBytes(file, f.Value); } //记录索引 MyJson.JsonNode_Object indexitem = new MyJson.JsonNode_Object(); indexitem["Name"] = new MyJson.JsonNode_ValueString("resources/" + f.Key); indexitem["Length"] = new MyJson.JsonNode_ValueNumber(f.Value.Length); indexfile.Add(indexitem); } indexfile.Sort((a, b) => { return string.Compare(a.asDict()["Name"].AsString(), b.asDict()["Name"].AsString()); }); {//保存索引文件 byte[] indexcode = System.Text.Encoding.UTF8.GetBytes(indexfile.ToString()); exportResult = exportNodeName; if (bUseHashTreeName) { exportResult = ResLibTool.ComputeHashString(indexcode); } string outfile = System.IO.Path.Combine(exportPath, exportResult + ".indexlist.txt"); System.IO.File.WriteAllBytes(outfile, indexcode); } }