Наследование: INodeParser
Пример #1
0
    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);
        }
    }
Пример #2
0
    void LoadItem(string filename)
    {
        string jsontxt = System.Text.Encoding.UTF8.GetString(System.IO.File.ReadAllBytes(filename));

        MyJson.JsonNode_Array       array = MyJson.Parse(jsontxt) as MyJson.JsonNode_Array;
        Dictionary <string, byte[]> bufs  = new Dictionary <string, byte[]>();

        foreach (MyJson.JsonNode_Object indexitem in array)
        {
            string name = indexitem["Name"].AsString();
            int    len  = indexitem["Length"].AsInt();
            bufs[System.IO.Path.GetFileName(name)] = System.IO.File.ReadAllBytes(exportPath + "/" + name);
            //Debug.Log(name);
        }
        nodeParser.nodeParser np = new nodeParser.nodeParser();

        np.SetBufs(bufs);
        np.GenNode();
    }
Пример #3
0
    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);
        }

    }
Пример #4
0
    void LoadItem(string filename)
    {
        string jsontxt = System.Text.Encoding.UTF8.GetString(System.IO.File.ReadAllBytes(filename));
        MyJson.JsonNode_Array array = MyJson.Parse(jsontxt) as MyJson.JsonNode_Array;
        Dictionary<string, byte[]> bufs = new Dictionary<string, byte[]>();
        foreach (MyJson.JsonNode_Object indexitem in array)
        {
            string name = indexitem["Name"].AsString();
            int len = indexitem["Length"].AsInt();
            bufs[System.IO.Path.GetFileName(name)] = System.IO.File.ReadAllBytes(exportPath + "/" + name);
            //Debug.Log(name);

        }
        nodeParser.nodeParser np = new nodeParser.nodeParser();

        np.SetBufs(bufs);
        np.GenNode();
    }
Пример #5
0
 public ResMgr(nodeParser _parser)
 {
     this.parser = _parser;
 }
Пример #6
0
 public ResMgr(nodeParser _parser)
 {
     this.parser = _parser;
 }