SeriousCache / UABE

Asset Bundle Extractor
3.55k stars 462 forks source link

Streamed assets #21

Closed ShadySt closed 7 years ago

ShadySt commented 8 years ago

Hi, I'm trying to modify .assets files for Darkwood with your tool (v.1.8.1). It said by developers that game is currently uses Unity v.5.3.1p3 and when I try to export 2D textures with png or tga plugin, program crashes. But sometimes textures exported correctly or exported as random chaotic range of pixels. Most of times it's just crashes. Can you help me with this issue? I can give you files or information you request.

DerPopo commented 8 years ago

Did you rename classdata_0E to something else and rename classdata_0E_5.3.1p3 to classdata_0E? The Texture2D format changed a bit in the last versions which might cause some exporting issues with old classdata files.

ShadySt commented 8 years ago

I did not renamed any of that because I'm not quite familiar with it. I just downloaded folder with UABE v.1.8.1 and used it to work with game assets.

DerPopo commented 8 years ago

Then renaming the file should solve it

ShadySt commented 8 years ago

I renamed "classdata_0E" to random name and renamed "classdata_0E_5.3.1p3" to "classdata_0E" which made no difference, same textures exports succesfully, others still crash the UABE. I attach link to the file that you can check by yourself, if you have some time: https://drive.google.com/file/d/0BySrwX8Q2_PkY2ZYdHJqTWdPTzA/view?usp=sharing

DerPopo commented 8 years ago

It seems like the game loads most of the textures from the .resS files (similar to AudioClip). I will look into adding this to the texture plugin.

ShadySt commented 8 years ago

Thanks, there are actually some .resS files with pretty big weight. If you do so, UABE will be the only and the best Unity 5 assets modding tool yet!

0x900x90 commented 8 years ago

Maybe you can make program loading different dat file depending on unity version. For example, if unity version is 5.3.xxx and up, program loads classdata_0E_5.3.xxx. If 5.2.xxx then classdata_0E_5.2.xxx.

I found that unity 5.3 stores most of imagedata blocks in external file. But some imagedata stored in the assets file itself. Compared 2 texture2d assets from 5.2 and 5.3 with internal imagedata. Not found any difference. Can't understand how unity decides where to store imagedata.

DerPopo commented 8 years ago

There is an additional reference to the streamed file (offset, size, filename) in 5.3 textures (that is just filled with 0s/empty filename for non-streamed data), similar to U5 AudioClips.

I will probably just store the unity version of a classdata file like 5.3.* (and compare that with the version found in the .assets file) to decide which one it should use.

0x900x90 commented 8 years ago

Yes, i just found these 12 bytes.

Good idea with the unity version.

DerPopo commented 8 years ago

Streamed Texture2D should work with the next release.

Created a type database package file format which can store multiple type databases and which has one optimized string table, saving additional space (for 5 different type databases with LZMA, it's 106KBs in single files vs. 68KBs in the package). Even though we are talking about KBs, I think this is a cleaner way (also because the tool doesn't have to test all files in the directory for the Unity version). As with type databases, there will also be a package editor in case anyone needs it.

ShadySt commented 8 years ago

Do you have any ideas about update release date?

DerPopo commented 8 years ago

If I don't find any significant bugs, I will probably release it this week.

ShadySt commented 8 years ago

I'm glad that you released new version, streamed assets are correctly extracted! Finally! Anyways, after I loaded changed texture and saved .assets file, there are still old textures showed up in game. What am I doing wrong? I checked that my new texture is absolutely inside of the .assets file.

DerPopo commented 8 years ago

That's strange. Did you use File->Save, save to another file name, close UABE and rename the new file so it matches the original name?

ShadySt commented 8 years ago

How I did it (.assets file is named "resources.assets": Option 1: 1) Loaded .assets from game folder where .resS files dislocated too. 2) Changed resources.assets and saved in random folder with original name. 3) Closed UABE, replaced resources.assets in game folder.

Option2: 1) Copied original resources.assets and resources.assets.resS in random folder. 2) Opened resources.assets copy and changed it. 3) Replaced original resources.assets by "File->Save" option.

As I said, if I reopen resources.assets with UABE, I can see that textures are changed and saved. But in game there are old textures loaded.

ShadySt commented 8 years ago

Update: I opened another sharedassets.assets files (there are 123 of them) and found same files I saw in resources.assets. Textures that I edited in resourses.assets are edited in all sharedassets files too.
I think that probably it's rather problem with my editing methods than with UABE but maybe you can give me advice, what I could do in this case? How game can load old textures if I changed them.

DerPopo commented 8 years ago

UABE also lists the assets of dependencies (resources.assets usually is a dependency). The file you actually opened has the assets with file id 0. One thing that's possible is that there is another equal Texture2D (usually in one of the level files without a file ending, or possibly in one sharedassets.assets). Try to export a dump of the original Texture2D, set the width and height to 0 or 1 and import the changed dump back in. If the game still shows the texture normally, there most likely is a duplicate of it somewhere.

ShadySt commented 8 years ago

Thank you for answer. There are no equal Textures2D, looks like problem in texture import. I deleted texture from .assets file and it dissapeared from game. Also changing texture format resoulted in changed look of texture in game. But still actual texture remained native. If I export my "changed" texture from .assets file it will export my custom texture but in game there are still native texture shown. I tried to import in both PNG and TGA formats. Maybe if I could somehow convert my custom Texture2D into raw data, I could try to import in that way. Or maybe I should look into texture import parameters? https://i.gyazo.com/88f75a07e28b8c595ac2e8aece117005.png

jayasafunctionofe commented 8 years ago

importing the Texture2D seems to have an issue with streamed assets, the texture is placed in the assets file not the resS file, even after saving the assets file the StreamingInfo m_StreamData in the exportDump of the Texture2D shows a string path = "resources.assets.resS", it seems like UABE needs to put the texture in the resS to allow the texture to be changed.

DerPopo commented 8 years ago

Files aren't saved in the .ress file because it's "glued together" (like all texture data copy&pasted after another) so e.g. saving a larger texture won't be a problem. New Unity versions still accept texture data inside an asset. I actually intended to clear m_StreamData but obviously that isn't done, so possibly Unity still loads the file from the .resS instead of the texture data array. It's fixed for the next release. In case it's urgent, you can also export the modified texture to a dump (it will possibly be a large file), set the m_StreamData path to "" and the offset/size to 0. Then import the dump back in.

jayasafunctionofe commented 8 years ago

thanks, doing a dump and changing the offset,size,path works until the next release comes out. just make sure you don't try to dump the texture right after editing it via the plugin (without saving and reloading), as it results in a BSOD.

DerPopo commented 8 years ago

I guess there's some kind of bug in a file system driver/in the kernel, I can't think of any other reasons why that should result in a BSOD even if there's a bug in UABE. Applications aren't supposed to be able to cause bluescreens.

ShadySt commented 7 years ago

It's been some time... I don't know what caused my problems, but now everything works perfect! The only feature that I miss is built in texture viewer. Thanks for your work, DerPopo.