public BundleFileInstance(Stream stream, string filePath, string root, bool unpackIfPacked) { this.stream = stream; 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); this.stream = file.reader.BaseStream; } loadedAssetsFiles = new List <AssetsFileInstance>(); }
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 AssetsFileInstance LoadAssetsFileFromBundle(BundleFileInstance bunInst, int index, bool loadDeps = false) { var dirInf = bunInst.file.bundleInf6.dirInf[index]; string assetMemPath = Path.Combine(bunInst.path, dirInf.name); int listIndex = files.FindIndex(f => f.path.ToLower() == Path.GetFullPath(assetMemPath).ToLower()); if (listIndex == -1) { if (bunInst.file.IsAssetsFile(bunInst.file.reader, dirInf)) { byte[] assetData = BundleHelper.LoadAssetDataFromBundle(bunInst.file, index); MemoryStream ms = new MemoryStream(assetData); AssetsFileInstance assetsInst = LoadAssetsFile(ms, assetMemPath, loadDeps, bunInst: bunInst); bunInst.assetsFiles.Add(assetsInst); return(assetsInst); } } else { return(files[listIndex]); } return(null); }