Beispiel #1
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();
            }
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }