zhangjiequan / AssetStudio

AssetStudio - Based on the archived Perfare's AssetStudio, I continue Perfare's work to keep AssetStudio up-to-date, with support for new Unity versions and additional improvements.
MIT License
1.05k stars 78 forks source link

Error while reading bundle file - System.IO.IOException: Lz4 decompression error, write -1 bytes but expected 131072 bytes #15

Open MGSimard opened 8 months ago

MGSimard commented 8 months ago

Game: Rise of Kingdoms Build: Unity 2021.3.21f1 File: ui_texturecommander.lb (Applies to all .lb UnityFS Bundle files for Rise of Kingdoms)

Error:

Error while reading bundle file C:\Users\MGS\Desktop\RoK\ui_texture_commander.lb

System.IO.IOException: Lz4 decompression error, write -1 bytes but expected 131072 bytes

   at AssetStudio.BundleFile.ReadBlocks(EndianBinaryReader reader, Stream blocksStream) in D:\a\AssetStudio\AssetStudio\AssetStudio\BundleFile.cs:line 351

   at AssetStudio.BundleFile..ctor(FileReader reader) in D:\a\AssetStudio\AssetStudio\AssetStudio\BundleFile.cs:line 98

   at AssetStudio.AssetsManager.LoadBundleFile(FileReader reader, String originalPath) in D:\a\AssetStudio\AssetStudio\AssetStudio\AssetsManager.cs:line 182

Issue reference from original 2022 build: https://github.com/Perfare/AssetStudio/issues/971#issue-1226264525

Solution: Delete all bit entries from the first "UnityFS" specification to the next "UnityFS" specification.

Originally posted by @p0pZeroSn in https://github.com/Perfare/AssetStudio/issues/971#issuecomment-1119429868

Other user who had trouble with solution:

Hey bro, after I follow what you said, it prompts that the dimension of the array is exceeded. Do you know why?

Originally posted by @PackageInstaller in https://github.com/Perfare/AssetStudio/issues/971#issuecomment-1120222134

If this specific niche use-case doesn't warrant a special fix, could there be any more specific explanation on how to execute @p0pZeroSn's alleged fix? Even if I delete everything from and to the first and second UnityFS declarations/headers/whatever, it still doesn't function.

MGSimard commented 8 months ago

Okay, found an actual partial fix, specifically for the files which contain "UnityFS" twice. Some of the files will still have very few assets which will fail, but the fix is as simple as CTRL+F to the second "UnityFS" entry and deleting everything before that.

This way, your edited file should now begin with the second UnityFS entry.

Result: image