jorgenpt / uasset-rs

Parsing of Unreal Engine asset files (uassets) in Rust
Apache License 2.0
91 stars 7 forks source link

Is it possible to modify and save the assets? #3

Open notdanilo opened 2 years ago

notdanilo commented 2 years ago

I am trying to implement a better asset manager to move assets around and fix the dependencies. I need to move a big folder which is losing more than 100 soft references.

jorgenpt commented 2 years ago

Currently there's no support for saving assets, but it is possible to use the code as a starting point to implement that. It's something I'd be willing to include & support if you decided to pursue that!

notdanilo commented 2 years ago

I started working on it yesterday and I am facing a problem with CustomVersions. I realized you only support if it's "enumerated" as Optimized. Do you have any idea how I can detect the other two formats?

notdanilo commented 2 years ago

I will continue working on it until Monday. If I can't get it working, I will have to drop the effort.

My plan is to:

  1. Directly look for the known asset references FStrings in the file and change then.
  2. As a consequence of 1., I need to update the offsets in the header and recalculate the header size.

I also faced another issue which the cause is still unknown: I used UE to edit a reference (adding one more character to the FString). I expected to see only 2 more bytes in the file ('cause the asset path has this /Game/Content/BP_File.BP_File_C repetition), but the file size increased a bit more than 100 bytes and it also affected the header size. Do you have any idea why it happened?

notdanilo commented 2 years ago

Responding to:

I started working on it yesterday and I am facing a problem with CustomVersions. I realized you only support if it's "enumerated" as Optimized. Do you have any idea how I can detect the other two formats?

We can get the enum out of the legacy version like this: https://github.com/EpicGames/UnrealEngine/blob/fbead6f0990207c6022b6d1ec49f14b16f39c270/Engine/Source/Runtime/CoreUObject/Private/UObject/PackageFileSummary.cpp#L14

jorgenpt commented 2 years ago

I used UE to edit a reference (adding one more character to the FString). I expected to see only 2 more bytes in the file ('cause the asset path has this /Game/Content/BP_File.BP_File_C repetition), but the file size increased a bit more than 100 bytes and it also affected the header size. Do you have any idea why it happened?

I don't know the reasons for this -- I know that the saves tend to be non-deterministics, but I didn't realize there would be as significant changes like that. I'd have to dig into the behavior to see what might be causing it.