Exemplo n.º 1
0
        public void Extract(SerializeObject obj, string outputPath)
        {
            Unity.Texture2D tex = new Unity.Texture2D();
            tex.Deserialize(obj.RootProperty);
            //string m_Name = obj.FindProperty("m_Name").Value as string;
            //int m_Width = (int)obj.FindProperty("m_Width").Value;
            //int m_Height = (int)obj.FindProperty("m_Height").Value;
            //int m_CompleteImageSize = (int)obj.FindProperty("m_CompleteImageSize").Value;
            //int m_TextureFormat = (int)obj.FindProperty("m_TextureFormat").Value;
            //byte[] data = (byte[])obj.FindProperty("image data").Value;
            //Bitmap bmp = new Bitmap(m_Width, m_Height, PixelFormat.Format32bppArgb);
            //var bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
            //int bytes = Math.Abs(bmpData.Stride) * bmp.Height;
            //IntPtr ptr = bmpData.Scan0;
            //System.Runtime.InteropServices.Marshal.Copy(data, 0, ptr, bytes);
            Image iamg;

            //bmp.UnlockBits(bmpData);
            outputPath = outputPath + "/" + tex.name + "." + tex.m_TextureFormat;
            outputPath = AssetToolUtility.FixOuputPath(outputPath);
            if (!Directory.Exists(Path.GetDirectoryName(outputPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            }
            File.WriteAllBytes(outputPath, tex.image_data);
            //bmp.Save(outputPath);
        }
Exemplo n.º 2
0
 public override void run()
 {
     extrator         = new AssetExtrator();
     typeTreeDatabase = AssetToolUtility.LoadTypeTreeDataBase(Resources.TypeTreeDataBasePath);
     base.run();
     AssetToolUtility.SaveTypeTreeDataBase(Resources.TypeTreeDataBasePath, typeTreeDatabase);
 }
Exemplo n.º 3
0
        private void learnFormAssetBundle(string path)
        {
            FileStream      fs     = new FileStream(path, FileMode.Open, FileAccess.Read);
            DataReader      br     = new DataReader(fs);
            SerializeBundle bundle = new SerializeBundle();

            bundle.DeSerialize(br);
            foreach (var bundleEntry in bundle.entrys)
            {
                int version         = AssetToolUtility.GetAssetsFileVersion(bundleEntry.assetData);
                var serializeAssets = SerializeAssetFactory.CreateWithVersion(version);
                if (serializeAssets != null)
                {
                    MemoryStream ms = new MemoryStream(bundleEntry.assetData);
                    DataReader   dr = new DataReader(ms);
                    serializeAssets.DeSerialize(dr);
                    var assetTypeTreeDB = AssetToolUtility.GenerateTypeTreeDataBase(serializeAssets);
                    if (assetTypeTreeDB != null)
                    {
                        var allType = assetTypeTreeDB.GetAllType(version);
                        foreach (var type in allType)
                        {
                            Console.WriteLine("AddType:Version:{0},ClassID{1},Name:{2}", version, type.Key, type.Value.type);
                        }
                    }
                    typeTreeDatabase = assetTypeTreeDB.Merage(typeTreeDatabase);
                }
                else
                {
                    Debug.LogError("can't deserialize bundle entry " + bundleEntry.name);
                }
                fs.Dispose();
            }
        }
Exemplo n.º 4
0
        private void DeserializeAsset(string path)
        {
            MemoryStream assetms = new MemoryStream();
            BinaryWriter bw      = new BinaryWriter(assetms);
            string       fileExt = Path.GetExtension(path);

            //处理Split文件
            if (fileExt.StartsWith(".split"))
            {
                string fileDir    = Path.GetDirectoryName(path);
                string fileName   = Path.GetFileNameWithoutExtension(path);
                int    splitIndex = 0;
                while (true)
                {
                    string splitFilePath = fileDir + "/" + fileName + ".split" + splitIndex.ToString();
                    splitIndex++;
                    if (!File.Exists(splitFilePath))
                    {
                        break;
                    }

                    FileStream   splitfs = new FileStream(splitFilePath, FileMode.Open, FileAccess.Read);
                    BinaryReader splitbr = new BinaryReader(splitfs);
                    bw.Write(splitbr.ReadBytes((int)splitbr.BaseStream.Length));
                    splitbr.Close();
                    splitfs.Dispose();
                }
            }
            else
            {
                //处理单文件
                FileStream   assetfs = new FileStream(path, FileMode.Open, FileAccess.Read);
                BinaryReader assetbr = new BinaryReader(assetfs);
                bw.Write(assetbr.ReadBytes((int)assetbr.BaseStream.Length));
                assetbr.Close();
                assetfs.Dispose();
            }
            assetms.Position = 0;
            int version         = AssetToolUtility.GetAssetsFileVersion(assetms);
            var serializeAssets = SerializeAssetFactory.CreateWithVersion(version);

            if (serializeAssets == null)
            {
                assetms.Dispose();
                Debug.LogError("Can't deserialize asset file {0}.Version:{1}", path, version);
                return;
            }
            DataReader data = new DataReader(assetms);

            serializeAssets.DeSerialize(data);
            if (serializeAssets != null)
            {
                var asset = new Asset(serializeAssets);
                runAssetFile(asset);
            }
            assetms.Dispose();
        }
Exemplo n.º 5
0
        public override void run()
        {
            TypeTreeDataBase typeTreeDatabase = AssetToolUtility.LoadTypeTreeDataBase(Resources.TypeTreeDataBasePath);
            var allVertions = typeTreeDatabase.GetAllVersion();

            if (version != -1)
            {
                if (classID != -1)
                {
                    if (typeTreeDatabase.Contains(version, classID))
                    {
                        var typeTree = typeTreeDatabase.GetType(version, classID);
                        Console.WriteLine("Version:{0},ClassID:{1},Type:{2}:\n{3}", version, classID, typeTree.type, typeTree);
                    }
                    else
                    {
                        Console.WriteLine("No Found TypeTree.");
                    }
                }
                else
                {
                    var allTypes = typeTreeDatabase.GetAllType(version);
                    Console.WriteLine("Version:{0} has {1}  typetree {2}", version, allVertions.Length, classID);
                    foreach (var kvr in allTypes)
                    {
                        Console.WriteLine("Version:{0},ClassID:{1},Type:{2}:\n{3}", version, kvr.Key, kvr.Value.type, kvr.Value);
                    }
                }
            }
            else
            {
                if (classID != -1)
                {
                    foreach (var version in allVertions)
                    {
                        if (typeTreeDatabase.Contains(version, classID))
                        {
                            var typeTree = typeTreeDatabase.GetType(version, classID);
                            Console.WriteLine("Version:{0},ClassID:{1},Type:{2}:\n{3}", version, classID, typeTree.type, typeTree);
                        }
                    }
                }
                else
                {
                    foreach (var version in allVertions)
                    {
                        var allTypes = typeTreeDatabase.GetAllType(version);
                        Console.WriteLine("Version:{0} has {1}  typetree", version, allVertions.Length);
                        foreach (var kvr in allTypes)
                        {
                            Console.WriteLine("Version:{0},ClassID:{1},Type:{2}:\n{3}", version, kvr.Key, kvr.Value.type, kvr.Value);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void learnFormAssetFile(string path)
        {
            FileStream fs              = new FileStream(path, FileMode.Open, FileAccess.Read);
            DataReader dr              = new DataReader(fs);
            int        version         = AssetToolUtility.GetAssetsFileVersion(path);
            var        serializeAssets = SerializeAssetFactory.CreateWithVersion(version);

            serializeAssets.DeSerialize(dr);
            var assetTypeTreeDB = AssetToolUtility.GenerateTypeTreeDataBase(serializeAssets);

            typeTreeDatabase = assetTypeTreeDB.Merage(typeTreeDatabase);
            dr.Close();
            fs.Dispose();
        }
Exemplo n.º 7
0
        public void Extract(SerializeObject obj, string outputPath)
        {
            Font font = new Font();

            font.Deserialize(obj.RootProperty);
            string name = font.name;

            outputPath = outputPath + "/" + name + ".ttf";
            outputPath = AssetToolUtility.FixOuputPath(outputPath);
            if (!Directory.Exists(Path.GetDirectoryName(outputPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            }
            File.WriteAllBytes(outputPath, font.FontData);
        }
Exemplo n.º 8
0
        public override void run()
        {
            mSizeDic.Clear();
            typeTreeDatabase = AssetToolUtility.LoadTypeTreeDataBase(Resources.TypeTreeDataBasePath);
            base.run();
            AssetToolUtility.SaveTypeTreeDataBase(Resources.TypeTreeDataBasePath, typeTreeDatabase);
            Console.WriteLine("TotalSize:{0} kb", totalSize / 1024.0f);
            var sortedDic = mSizeDic.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

            foreach (var kvp in sortedDic)
            {
                string className = AssetToolUtility.ClassIDToClassName(kvp.Key);
                Console.WriteLine("{0,-30} Size:{1,-15}kb {2,-15}%", className, kvp.Value / 1024.0f, (kvp.Value / (float)totalSize) * 100);
            }
        }
Exemplo n.º 9
0
 public override void runFileRecursive(string path)
 {
     if (AssetToolUtility.IsBundle(path))
     {
         //try {
         learnFormAssetBundle(path);
         //} catch {
         //   Console.WriteLine("Can't open asset bundle " + path);
         //}
     }
     else
     {
         try {
             learnFormAssetFile(path);
         } catch {
             Console.WriteLine("Can't open asset file " + path);
         }
     }
 }
Exemplo n.º 10
0
        public void Extract(SerializeObject obj, string outputPath)
        {
            TextAsset textAsset = new TextAsset();

            textAsset.Deserialize(obj.RootProperty);
            string name   = textAsset.name;
            string script = "";

            outputPath = outputPath + "/" + name + ".txt";
            outputPath = AssetToolUtility.FixOuputPath(outputPath);
            if (!Directory.Exists(Path.GetDirectoryName(outputPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            }
            var bytes = System.Text.Encoding.Unicode.GetBytes(script);
            var fs    = new FileStream(outputPath, FileMode.OpenOrCreate, FileAccess.Write);

            fs.Write(bytes, 0, bytes.Length);
            fs.Flush();
            fs.Dispose();
        }
Exemplo n.º 11
0
 public override void run()
 {
     extrator = new AssetExtrator();
     db       = AssetToolUtility.LoadTypeTreeDataBase(Properties.Resources.TypeTreeDataBasePath);
     base.run();
 }