Пример #1
0
        private void LoadBundleFile(string path)
        {
            OpenBundleDialog openFile = new OpenBundleDialog(helper, path);

            openFile.ShowDialog();
            if (openFile.selection > -1)
            {
                AssetBundleFile    bundleFile = openFile.file;
                BundleFileInstance bundleInst = openFile.inst;
                List <byte[]>      files      = BundleHelper.LoadAllAssetsDataFromBundle(bundleFile);
                if (files.Count > 0)
                {
                    if (files.Count > 1)
                    {
                        for (int i = 1; i < files.Count; i++)
                        {
                            MemoryStream       stream = new MemoryStream(files[i]);
                            string             name   = bundleFile.bundleInf6.dirInf[i].name;
                            AssetsFileInstance inst   = helper.LoadAssetsFile(stream, name, openFile.selection == 1);
                            inst.parentBundle = bundleInst;
                        }
                    }
                    MemoryStream       mainStream = new MemoryStream(files[0]);
                    string             mainName   = bundleFile.bundleInf6.dirInf[0].name;
                    AssetsFileInstance mainInst   = helper.LoadAssetsFile(mainStream, mainName, openFile.selection == 1);
                    mainInst.parentBundle = bundleInst;
                    LoadMainAssetsFile(mainInst);
                }
                else
                {
                    MessageBox.Show("No valid assets files found in the bundle.", "Assets View");
                }
            }
        }
Пример #2
0
    //不是孩子 也不是成员 也不是自己 则是依赖
    private void GetDepencyFiles(UnityEngine.Object obj)
    {
        if (obj == null)
        {
            return;
        }
        Debug.Log("Col: " + obj);
        var op = AssetDatabase.GetAssetPath(obj);

        if (!resFiles.ContainsKey(op))
        {
            var nf = new ResourceFile()
            {
                path = op,
                obj  = obj,
            };
            resFiles.Add(op, nf);
            openFiles.Add(nf);

            var dirName = Path.GetDirectoryName(op);
            if (!abFiles.ContainsKey(dirName))
            {
                var ab = new AssetBundleFile()
                {
                    path = dirName,
                };
                abFiles.Add(dirName, ab);
            }

            var abF = abFiles [dirName];
            abF.resources.Add(nf);
            nf.assetBundleFile = abF.path;
        }
    }
Пример #3
0
        private void decompressButton_Click(object sender, System.EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.FileName = Path.GetFileName(bundleStream.Name) + ".unpacked";
            sfd.Filter   = "All types (*.*)|*.*";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                note.Text = "Decompressing...";
                decompressButton.Enabled = false;
                bundleFilename           = sfd.FileName;
                FileStream       fileStream = new FileStream(sfd.FileName, FileMode.Create);
                BackgroundWorker bw         = new BackgroundWorker();
                bw.DoWork += delegate
                {
                    bundle.Unpack(reader, new AssetsFileWriter(fileStream));
                    fileStream.Position = 0;
                    bundle = new AssetBundleFile();
                    bundle.Read(new AssetsFileReader(fileStream), false);
                    fileStream.Close();
                };
                bw.RunWorkerCompleted += delegate
                {
                    note.Text = "Done. Click Load to open the file.";
                    decompressButton.Enabled = false;
                    loadButton.Enabled       = true;
                };
                bw.RunWorkerAsync();
            }
        }
Пример #4
0
        private static AssetBundleFile DecompressBundle(string file, string?decompFile)
        {
            AssetBundleFile bun = new AssetBundleFile();

            Stream           fs = File.OpenRead(file);
            AssetsFileReader r  = new AssetsFileReader(fs);

            bun.Read(r, true);
            if (bun.bundleHeader6.GetCompressionType() != 0)
            {
                Stream nfs;
                if (decompFile == null)
                {
                    nfs = new MemoryStream();
                }
                else
                {
                    nfs = File.Open(decompFile, FileMode.Create, FileAccess.ReadWrite);
                }

                AssetsFileWriter w = new AssetsFileWriter(nfs);
                bun.Unpack(r, w);

                nfs.Position = 0;
                fs.Close();

                fs = nfs;
                r  = new AssetsFileReader(fs);

                bun = new AssetBundleFile();
                bun.Read(r, false);
            }

            return(bun);
        }
        public OpenBundleDialog(AssetsManager helper, string filePath)
        {
            InitializeComponent();
            this.filePath = filePath;
            fileName      = Path.GetFileName(filePath);
            inst          = helper.LoadBundleFile(filePath);
            file          = inst.file;
            uint compressionMethod = file.bundleHeader6.flags & 0x3F;

            if (compressionMethod == 0)
            {
                justThisFile.Enabled        = true;
                fileAndDependencies.Enabled = true;
                compressBundle.Enabled      = true;
                status.Text = $"Opening bundle file {fileName}...";
            }
            else
            {
                decompressBundle.Enabled         = true;
                decompressBundleInMemory.Enabled = true;
                if (compressionMethod == 1)
                {
                    status.Text = $"Opening bundle file {fileName} (LZMA)...";
                }
                else if (compressionMethod == 2 || compressionMethod == 3)
                {
                    status.Text = $"Opening bundle file {fileName} (LZ4)...";
                }
                else
                {
                    status.Text = $"Opening bundle file {fileName} (???)...";
                }
            }
        }
Пример #6
0
        /// <summary>
        /// 导入一整个目录的资源文件
        /// </summary>
        /// <param name="directoryPath"></param>
        /// <param name="targetFileName"></param>
        public static void ImportAssets(string directoryPath, string targetFileName)
        {
            if (Directory.Exists(directoryPath))
            {
                var files    = Directory.GetFiles(directoryPath);
                var replList = new List <AssetsReplacer>();

                //清空LOG文件
                logPath = Path.GetFileNameWithoutExtension(targetFileName) + ".txt";
                File.WriteAllText(logPath, "", Encoding.UTF8);

                for (int i = 0; i < files.Length; i++)
                {
                    //锁定范围(920,1000]
                    //if (i >= 920 && i <= 960) continue;
                    //if (i >= 1000 && i <= 1500) continue;
                    //if (i >= int.Parse(arr[0]) && i <= int.Parse(arr[1])) continue;

                    var    splitArr = Path.GetFileNameWithoutExtension(files[i]).Split(new string[] { "--" }, StringSplitOptions.None);
                    string name;

                    if (splitArr.Length == 2)
                    {
                        name = splitArr[1];
                    }
                    else
                    {
                        name = splitArr[3];
                    }

                    var temp = GenReplacerFromMemory(long.Parse(name), files[i], splitArr);
                    //var temp = GenReplacerFromMemoryByJson(long.Parse(name), files[i]);

                    if (temp != null)
                    {
                        replList.Add(temp);
                    }
                }

                var inst   = IEManager.AssetsFileInstance;
                var writer = new AssetsFileWriter(File.OpenWrite(targetFileName));
                //Bundle和普通的分离操作
                if (IEManager.IsBundle)
                {
                    AssetBundleFile          abFile   = inst.parentBundle.file;
                    var                      index    = FindAssetsIDInBundle(inst, abFile);
                    BundleReplacerFromAssets brfa     = new BundleReplacerFromAssets(Path.GetFileName(inst.path), null, inst.file, replList, index);
                    List <BundleReplacer>    bRepList = new List <BundleReplacer>();
                    bRepList.Add(brfa);
                    abFile.Write(writer, bRepList);
                }
                else
                {
                    inst.file.Write(writer, 0, replList, 0);
                }

                writer.Close();
            }
        }
Пример #7
0
        public static AssetsFile LoadAssetFromBundle(AssetBundleFile bundle, int index)
        {
            bundle.GetFileRange(index, out long offset, out long length);
            Stream           stream = new SegmentStream(bundle.reader.BaseStream, offset, length);
            AssetsFileReader reader = new AssetsFileReader(stream);

            return(new AssetsFile(reader));
        }
Пример #8
0
        public static AssetsFile LoadAssetFromBundle(AssetBundleFile bundle, int index)
        {
            byte[]           data = LoadAssetDataFromBundle(bundle, index);
            MemoryStream     ms   = new MemoryStream(data);
            AssetsFileReader r    = new AssetsFileReader(ms);

            return(new AssetsFile(r));
        }
 public BundleFileInstance(Stream stream, string filePath, string root)
 {
     this.stream = stream;
     path        = Path.GetFullPath(filePath);
     name        = Path.Combine(root, Path.GetFileName(path));
     file        = new AssetBundleFile();
     file.Read(new AssetsFileReader(stream), true);
     assetsFiles = new List <AssetsFileInstance>();
 }
Пример #10
0
        public static byte[] LoadAssetDataFromBundle(AssetBundleFile bundle, int index)
        {
            bundle.GetFileRange(index, out long offset, out long length);

            AssetsFileReader reader = bundle.reader;

            reader.Position = offset;
            return(reader.ReadBytes((int)length));
        }
Пример #11
0
        public static byte[] LoadAssetDataFromBundle(AssetBundleFile bundle, int index)
        {
            AssetsFileReader reader = bundle.reader;
            int start  = (int)(bundle.bundleHeader6.GetFileDataOffset() + bundle.bundleInf6.dirInf[index].offset);
            int length = (int)bundle.bundleInf6.dirInf[index].decompressedSize;

            reader.Position = start;
            return(reader.ReadBytes(length));
        }
        public IEnumerable <AssetFile> BuildAssetsFileInstance(Stream stream)
        {
            List <AssetFile> result = new List <AssetFile>();

            classPackage = new ClassDatabasePackage();
            Console.WriteLine("Reading class-data...");
            using (var reader = new AssetsFileReader(new FileStream("classdata.tpk", FileMode.Open, FileAccess.Read, FileShare.Read))) {
                classPackage.Read(reader);
            }

            var file = new AssetBundleFile();

            activeBundleFile = file;
            Console.WriteLine("Reading bundleFileStream...");
            file.Read(new AssetsFileReader(stream), true);
            file.reader.Position = 0;
            Stream memoryStream = new MemoryStream();

            Console.WriteLine("Unpacking bundleFile...");
            file.Unpack(file.reader, new AssetsFileWriter(memoryStream));
            memoryStream.Position = 0;
            file.Close();
            file = new AssetBundleFile();
            file.Read(new AssetsFileReader(memoryStream));

            Console.WriteLine("file.bundleInf6.dirInf.Length: " + file.bundleInf6.dirInf.Length);

            for (int i = 0; i < file.bundleInf6.dirInf.Length; i++)
            {
                try {
                    if (file.IsAssetsFile(file.reader, file.bundleInf6.dirInf[i]))
                    {
                        byte[] assetData  = BundleHelper.LoadAssetDataFromBundle(file, i);
                        var    mainStream = new MemoryStream(assetData);
                        activeStreams.Add(mainStream);

                        string            mainName     = file.bundleInf6.dirInf[i].name;
                        var               fileInstance = new AssetsFileInstance(mainStream, mainName, "");
                        ClassDatabaseFile classDBFile  = LoadClassDatabaseFromPackage(fileInstance.file.typeTree.unityVersion);
                        if (classDBFile == null)
                        {
                            Console.WriteLine("classDatabaseFile was null? Okay, that's probably bad. Continuing anyway...");
                        }

                        result.Add(new AssetFile(fileInstance, classDBFile));
                    }
                } catch (Exception e) {
                    Console.WriteLine("caught exception while reading AssetsFile: " + e);
                    //guess it's not an assetsFile then?
                }
            }

            Console.WriteLine("found " + result.Count + " AssetFiles");

            return(result);
        }
Пример #13
0
        public static AssetsFile LoadAssetFromBundle(AssetBundleFile bundle, string name)
        {
            int index = bundle.GetFileIndex(name);

            if (index < 0)
            {
                return(null);
            }

            return(LoadAssetFromBundle(bundle, index));
        }
Пример #14
0
        public static bool IsBundleDataCompressed(AssetBundleFile bundle)
        {
            AssetsFileReader reader = bundle.reader;

            reader.Position = bundle.bundleHeader6.GetBundleInfoOffset();
            MemoryStream     blocksInfoStream;
            AssetsFileReader memReader;
            int compressedSize = (int)bundle.bundleHeader6.compressedSize;

            byte[] uncompressedBytes;
            switch (bundle.bundleHeader6.GetCompressionType())
            {
            case 1:
                uncompressedBytes = new byte[bundle.bundleHeader6.decompressedSize];
                using (MemoryStream mstream = new MemoryStream(reader.ReadBytes(compressedSize)))
                {
                    MemoryStream decoder = SevenZipHelper.StreamDecompress(mstream, compressedSize);
                    decoder.Read(uncompressedBytes, 0, (int)bundle.bundleHeader6.decompressedSize);
                    decoder.Dispose();
                }
                blocksInfoStream = new MemoryStream(uncompressedBytes);
                break;

            case 2:
            case 3:
                uncompressedBytes = new byte[bundle.bundleHeader6.decompressedSize];
                using (MemoryStream mstream = new MemoryStream(reader.ReadBytes(compressedSize)))
                {
                    var decoder = new Lz4DecoderStream(mstream);
                    decoder.Read(uncompressedBytes, 0, (int)bundle.bundleHeader6.decompressedSize);
                    decoder.Dispose();
                }
                blocksInfoStream = new MemoryStream(uncompressedBytes);
                break;

            default:
                blocksInfoStream = null;
                break;
            }

            var uncompressedInf = bundle.bundleInf6;

            if (bundle.bundleHeader6.GetCompressionType() != 0)
            {
                using (memReader = new AssetsFileReader(blocksInfoStream))
                {
                    memReader.Position = 0;
                    uncompressedInf    = new AssetBundleBlockAndDirectoryList06();
                    uncompressedInf.Read(0, memReader);
                }
            }

            return(uncompressedInf.blockInf.Any(inf => (inf.flags & 0x3f) != 0));
        }
Пример #15
0
        public static uint FindAssetsIDInBundle(AssetsFileInstance inst, AssetBundleFile abFile)
        {
            for (uint i = 0; i < abFile.bundleInf6.dirInf.Length; i++)
            {
                if (inst.name == abFile.bundleInf6.dirInf[i].name)
                {
                    return(i);
                }
            }

            throw new Exception("找不到AssetsFile在AB包中的index");
        }
Пример #16
0
 public BundleFileInstance(FileStream stream, string root)
 {
     this.stream = stream;
     path        = stream.Name;
     name        = Path.Combine(root, Path.GetFileName(path));
     file        = new AssetBundleFile();
     file.Read(new AssetsFileReader(stream), true);
     assetsFiles.AddRange(
         Enumerable.Range(0, (int)file.bundleInf6.blockCount)
         .Select(d => (AssetsFileInstance)null)
         );
 }
Пример #17
0
 public BundleFileInstance(Stream stream, string filePath, string root, bool unpackIfPacked)
 {
     path = Path.GetFullPath(filePath);
     name = Path.Combine(root, Path.GetFileName(path));
     file = new AssetBundleFile();
     file.Read(new AssetsFileReader(stream), true);
     if (file.bundleHeader6 != null && file.bundleHeader6.GetCompressionType() != 0 && unpackIfPacked)
     {
         file = BundleHelper.UnpackBundle(file);
     }
     loadedAssetsFiles = new List <AssetsFileInstance>();
 }
Пример #18
0
        private static void BatchExport(string[] args)
        {
            string           mainFileName = GetMainFileName(args);
            HashSet <string> flags        = GetFlags(args);
            HashSet <string> files        = GetAllFilesFromBatchFile(mainFileName);

            foreach (string file in files)
            {
                string decompFile = $"{file}.decomp";
                string filePath   = Path.GetDirectoryName(file);

                if (flags.Contains("-md"))
                {
                    decompFile = null;
                }

                if (!File.Exists(file))
                {
                    Console.WriteLine($"File {file} does not exist!");
                    return;
                }
                Console.WriteLine($"Decompressing {file}...");
                AssetBundleFile bun = DecompressBundle(file, decompFile);

                int entryCount = bun.bundleInf6.dirInf.Length;
                for (int i = 0; i < entryCount; i++)
                {
                    string name = bun.bundleInf6.dirInf[i].name;
                    byte[] data = BundleHelper.LoadAssetDataFromBundle(bun, i);
                    string outName;
                    if (flags.Contains("-keepnames"))
                    {
                        outName = Path.Combine(filePath, $"{name}.assets");
                    }
                    else
                    {
                        outName = Path.Combine(filePath, $"{Path.GetFileName(file)}_{name}.assets");
                    }
                    Console.WriteLine($"Exporting {outName}...");
                    File.WriteAllBytes(outName, data);
                }

                bun.Close();

                if (!flags.Contains("-kd") && !flags.Contains("-md") && File.Exists(decompFile))
                {
                    File.Delete(decompFile);
                }

                Console.WriteLine("Done.");
            }
        }
Пример #19
0
 public static byte[] LoadAssetDataFromBundle(AssetBundleFile bundle, string name)
 {
     AssetBundleDirectoryInfo06[] dirInf = bundle.bundleInf6.dirInf;
     for (int i = 0; i < dirInf.Length; i++)
     {
         AssetBundleDirectoryInfo06 info = dirInf[i];
         if (info.name == name)
         {
             return(LoadAssetDataFromBundle(bundle, i));
         }
     }
     return(null);
 }
 public BundleFileInstance(FileStream stream, string root, bool unpackIfPacked)
 {
     this.stream = stream;
     path        = stream.Name;
     name        = Path.Combine(root, Path.GetFileName(path));
     file        = new AssetBundleFile();
     file.Read(new AssetsFileReader(stream), true);
     if (file.bundleHeader6.GetCompressionType() != 0 && unpackIfPacked)
     {
         file = BundleHelper.UnpackBundle(file);
     }
     assetsFiles = new List <AssetsFileInstance>();
 }
Пример #21
0
 public static AssetBundleDirectoryInfo06 GetDirInfo(AssetBundleFile bundle, string name)
 {
     AssetBundleDirectoryInfo06[] dirInf = bundle.bundleInf6.dirInf;
     for (int i = 0; i < dirInf.Length; i++)
     {
         AssetBundleDirectoryInfo06 info = dirInf[i];
         if (info.name == name)
         {
             return(info);
         }
     }
     return(null);
 }
Пример #22
0
        static void Main(string[] args)
        {
            var currentDir = new DirectoryInfo(@".");
            var files      = currentDir.GetFiles("*.unity3d");

            foreach (var file in files)
            {
                AssetBundleFile bundle = new AssetBundleFile();
                bundle.Read(new UnityBinaryReader(file.FullName));

                Console.WriteLine("Loading " + file.Name);

                AssetsFile assets = new AssetsFile();
                assets.Read(new UnityBinaryReader(bundle.Files[0].Data));

                for (int typeid = 0; typeid < assets.Types.Length; typeid++)
                {
                    if (assets.Types[typeid].ClassID == (int)ClassIDType.AssetBundle)
                    {
                        continue;
                    }

                    var des = DynamicAsset.GetDeserializer(assets.Types[typeid]);
                    var ser = DynamicAsset.GetSerializer(assets.Types[typeid]);

                    Console.WriteLine("Checking " + assets.Types[typeid].TypeTree.Nodes[0].Type);

                    foreach (var obj in assets.Objects.Where(obj => obj.TypeID == typeid))
                    {
                        byte[]            org   = obj.Data;
                        var               asset = des(new UnityBinaryReader(org));
                        UnityBinaryWriter w     = new UnityBinaryWriter();
                        ser(w, asset);
                        byte[] result = w.ToBytes();

                        for (int i = 0; i < result.Length; i++)
                        {
                            if (result[i] != org[i])
                            {
                                throw new Exception();
                            }
                        }
                        string name = asset.HasMember("m_Name") ? asset.AsDynamic().m_Name : "(unnamed asset)";
                        Console.WriteLine(name + " Passed for check (" + result.Length + "bytes)");
                    }
                }
            }

            Console.WriteLine("Check has done.");
            System.Console.ReadLine();
        }
Пример #23
0
        public static List <AssetsFile> LoadAllAssetsFromBundle(AssetBundleFile bundle)
        {
            List <AssetsFile> files = new List <AssetsFile>();
            int numFiles            = bundle.NumFiles;

            for (int i = 0; i < numFiles; i++)
            {
                if (bundle.IsAssetsFile(i))
                {
                    files.Add(LoadAssetFromBundle(bundle, i));
                }
            }
            return(files);
        }
Пример #24
0
        public static AssetBundleFile CreateBlankBundle(string engineVersion, int contentSize)
        {
            AssetBundleHeader06 header = new AssetBundleHeader06()
            {
                signature         = "UnityFS",
                fileVersion       = 6,
                minPlayerVersion  = "5.x.x",
                fileEngineVersion = engineVersion,
                totalFileSize     = 0x82 + engineVersion.Length + contentSize,
                compressedSize    = 0x5B,
                decompressedSize  = 0x5B,
                flags             = 0x40
            };
            AssetBundleBlockInfo06 blockInf = new AssetBundleBlockInfo06
            {
                decompressedSize = (uint)contentSize,
                compressedSize   = (uint)contentSize,
                flags            = 0x0040
            };
            AssetBundleDirectoryInfo06 dirInf = new AssetBundleDirectoryInfo06
            {
                offset           = 0,
                decompressedSize = (uint)contentSize,
                flags            = 4,
                name             = GenerateCabName()
            };
            AssetBundleBlockAndDirectoryList06 info = new AssetBundleBlockAndDirectoryList06()
            {
                checksumLow  = 0,
                checksumHigh = 0,
                blockCount   = 1,
                blockInf     = new AssetBundleBlockInfo06[]
                {
                    blockInf
                },
                directoryCount = 1,
                dirInf         = new AssetBundleDirectoryInfo06[]
                {
                    dirInf
                }
            };
            AssetBundleFile bundle = new AssetBundleFile()
            {
                bundleHeader6 = header,
                bundleInf6    = info
            };

            return(bundle);
        }
Пример #25
0
        public static AssetBundleFile UnpackBundleToStream(AssetBundleFile file, Stream stream, bool freeOriginalStream = true)
        {
            file.Unpack(file.reader, new AssetsFileWriter(stream));
            stream.Position = 0;

            AssetBundleFile newFile = new AssetBundleFile();

            newFile.Read(new AssetsFileReader(stream), false);

            if (freeOriginalStream)
            {
                file.reader.Close();
            }
            return(newFile);
        }
Пример #26
0
        private void DecompressToFile(string savePath)
        {
            var bundleStream = File.Open(savePath, FileMode.Create);

            BundleInst.file.Unpack(BundleInst.file.reader, new AssetsFileWriter(bundleStream));

            bundleStream.Position = 0;

            var newBundle = new AssetBundleFile();

            newBundle.Read(new AssetsFileReader(bundleStream));

            BundleInst.file.reader.Close();
            BundleInst.file = newBundle;
        }
Пример #27
0
        private void DecompressToMemory()
        {
            var bundleStream = new MemoryStream();

            BundleInst.file.Unpack(BundleInst.file.reader, new AssetsFileWriter(bundleStream));

            bundleStream.Position = 0;

            var newBundle = new AssetBundleFile();

            newBundle.Read(new AssetsFileReader(bundleStream));

            BundleInst.file.reader.Close();
            BundleInst.file = newBundle;
        }
Пример #28
0
        public static List <AssetsFile> LoadAllAssetsFromBundle(AssetBundleFile bundle)
        {
            List <AssetsFile> files  = new List <AssetsFile>();
            AssetsFileReader  reader = bundle.reader;

            AssetBundleDirectoryInfo06[] dirInf = bundle.bundleInf6.dirInf;
            for (int i = 0; i < dirInf.Length; i++)
            {
                AssetBundleDirectoryInfo06 info = dirInf[i];
                if (bundle.IsAssetsFile(reader, info))
                {
                    files.Add(LoadAssetFromBundle(bundle, i));
                }
            }
            return(files);
        }
Пример #29
0
 public BundleFileInstance(FileStream stream, string root, bool unpackIfPacked)
 {
     this.stream = stream;
     path        = stream.Name;
     name        = Path.Combine(root, Path.GetFileName(path));
     file        = new AssetBundleFile();
     file.Read(new AssetsFileReader(stream), true);
     if (file.bundleHeader6.GetCompressionType() != 0 && unpackIfPacked)
     {
         file = BundleHelper.UnpackBundle(file);
     }
     assetsFiles.AddRange(
         Enumerable.Range(0, file.bundleInf6.blockCount)
         .Select(d => (AssetsFileInstance)null)
         );
 }
        public void CloseActiveStreams()
        {
            for (int i = 0; i < activeStreams.Count; i++)
            {
                activeStreams[i].Dispose();
                activeStreams[i] = null;
            }

            activeStreams = new List <MemoryStream>();

            if (activeBundleFile != null)
            {
                activeBundleFile.Close();
                activeBundleFile = null;
            }
        }
Пример #31
0
	private IEnumerator DownloadAssetBundle(AssetBundleFile assetBundleFile)
	{
		string url = assetBundleFile.assetBundleURL; 
		int version = assetBundleFile.assetBundleVersion;
		
		yield return StartCoroutine(AssetBundleManager.DownloadAssetBundle(url,version));
		AssetBundle assetBundle = AssetBundleManager.GetAssetBundle(url,version);
		
		if(assetBundle != null)
		{
			GameObject model = Instantiate(assetBundle.mainAsset) as GameObject;
			model.transform.parent = target.transform;
			model.transform.localScale = assetBundleFile.scaleAsset;
			
			CheckOnDownloadsComplete();
		}
	}
Пример #32
0
	private List<AssetBundleFile> GetAssetBundlesFiles(ArrayList assetBundlesFiles)
	{
		List<AssetBundleFile> assetBundles = new List<AssetBundleFile>();
		
		foreach(Hashtable assetBundleFile in assetBundlesFiles)
		{
			AssetBundleFile assetContainer = new AssetBundleFile();
			string assetBundleVersion = assetBundleFile["assetBundleVersion"].ToString();
			string assetBundleScale = assetBundleFile["scaleAsset"].ToString();
			
			assetContainer.assetBundleURL = assetBundleFile["assetBundle"].ToString();
			assetContainer.assetBundleVersion = int.Parse( assetBundleVersion );
			assetContainer.scaleAsset = ParseScale( assetBundleScale );
			assetBundles.Add( assetContainer );
		}
		
		return assetBundles;
	}