nesrak1 / UABEA

c# uabe for newer versions of unity
MIT License
1.15k stars 149 forks source link

Is there a way to edit 'Path ID' of assets? #333

Open Daelomin2 opened 5 months ago

Daelomin2 commented 5 months ago

I am trying to figure out a way to add brand new bundles of a certain type to a game for modding purposes. The only realistic way to do this is to modify the assets of an existing bundle to reflect the changes wanted for the 'new' bundle.

This process works perfectly in the game, EXCEPT for when the entity related to the 'new' bundle is loaded in a scene that contains the entity of the 'source' bundle: the game only loads one of the bundles and then prints an error to the log saying that the other bundle "can't be loaded because another AssetBundle with the same files is already loaded".

Unless I am mistaken, this error is occurring because both AssetBundles contain matching files with the exact same Path IDs. What I would like to try is to (using dumps and Pythin scripts) change all the Path IDs of the assets within the bundles to new Path IDs, and then edit all internal references to reflect the new Path IDs of the assets. I can edit the referenced Path IDs in individual Assets easy enough... but I can't seem to find a way to edit the Path ID itself of any given Asset within the bundle.

I hope this makes sense!

Daelomin2 commented 5 months ago

I should note that there is an "AssetBundle" asset within the bundle that contains all asset Path IDs referenced within the bundle (both internal and external) but editing the 'm_PathID' of an internal asset in this AssetBundle asset does not appear to update the 'Path ID' of the asset in question after saving and reloading the bundle.

Also, I have noted that it is possible to 'Add' an asset to the bundle and it appears I can set my own Path ID to any new asset, but when we're working with a bundle with 600 assets I'm really hoping I don't have to manually generate 600 new assets in order to get new Path IDs, rather than just edit the Path IDs of the existing assets!

nesrak1 commented 5 months ago

That error happens when your bundle's assets file name is the same as one already loaded.

Picture a bundle like a zip file that holds a folder of assets called folder1, and even though you can copy file1.zip to file2.zip, the folder inside is still the same name as file1's, and when unity tries to "extract" the zip, it would overwrite the files in folder1.

When you have a bundle open (the main window with the dropdown and info button), you can click rename to rename the file to something else that doesn't conflict (usually something like CAB- but doesn't have to be). You might have some issues with Texture2Ds, AudioClips, Meshes, and other assets inside the assets file (colored purple in the dropdown) because they have strings that reference a .resS file or .resource file by name. Currently, the only solution to this is to batch export dump all of those assets, find and replace the CAB- names or whatever they're called, and batch import all of them again. This rename step is a planned feature for UABEANext in the future.