C# 数据解包

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BinaryPacker
{
    class ReadAtlasData
    {
        public static void Pack(string path, string outFile) {
            FileStream fileStream3 = File.OpenRead( path + ".meta");
            string strValue = "";
            BinaryReader binaryReader3 = new BinaryReader(fileStream3);
            int version = binaryReader3.ReadInt32();
            strValue += "version:\t" + version.ToString() + "\r\n";
            string strpack =binaryReader3.ReadString();
            strValue += "pack:\t" + strpack + "\r\n";
            int msg = binaryReader3.ReadInt32();
            strValue += "msg:\t" + msg.ToString() + "\r\n";
            short num13 = binaryReader3.ReadInt16();
            strValue += "长度:\t" + num13.ToString() + "\r\n";
            strValue += "{\r\n";
            for (int m = 0; m < (int)num13; m++)
            {
                string str3 = binaryReader3.ReadString();
                strValue += "数据:\t" + str3 + "\r\n";
                //VirtualTexture virtualTexture5 = VirtualContent.CreateTexture(Path.Combine(Path.GetDirectoryName(path), str3 + ".data"));
                //atlas.Sources.Add(virtualTexture5);
                //MTexture parent4 = new MTexture(virtualTexture5);
                short num14 = binaryReader3.ReadInt16();
                strValue += "长度:\t" + num14.ToString() + "\r\n";
                strValue += "\t{\r\n";
                for (int n = 0; n < (int)num14; n++)
                {
                    string text5 = binaryReader3.ReadString().Replace('\\', '/');
                    short num15 = binaryReader3.ReadInt16();
                    short num16 = binaryReader3.ReadInt16();
                    short num17 = binaryReader3.ReadInt16();
                    short num18 = binaryReader3.ReadInt16();
                    short num19 = binaryReader3.ReadInt16();
                    short num20 = binaryReader3.ReadInt16();
                    short width2 = binaryReader3.ReadInt16();
                    short height2 = binaryReader3.ReadInt16();
                    // atlas.textures[text5] = new MTexture(parent4, text5, new Rectangle((int)num15, (int)num16, (int)num17, (int)num18), new Vector2((float)(-(float)num19), (float)(-(float)num20)), (int)width2, (int)height2);
                    strValue += "\t\t" + text5 + "\r\n";
                    strValue += "\t\t" + num15.ToString() + "\r\n";
                }
                strValue += "\t}\r\n";
            }
            strValue += "}\r\n";

            if (fileStream3.Position < fileStream3.Length && binaryReader3.ReadString() == "LINKS")
            {
                strValue += "{\r\n";
                short num21 = binaryReader3.ReadInt16();
                for (int num22 = 0; num22 < (int)num21; num22++)
                {
                    string key = binaryReader3.ReadString();
                    string value = binaryReader3.ReadString();
                    strValue += key  + "\t:\t" + value + "\r\n";
                }
                strValue += "}\r\n";
            }


            File.WriteAllText(outFile, strValue);

        }
    }
}
 

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值