K0lb3 / UnityPy

UnityPy is python module that makes it possible to extract/unpack and edit Unity assets
MIT License
771 stars 114 forks source link

Handle relative and case insensitive file paths #191

Closed sparr closed 9 months ago

sparr commented 1 year ago

This PR resolves a few problems I had exporting assets from the game Autonauts.

  1. One assets file contains a reference to another with a relative path, which UnityPy was trying to load from the script's CWD instead of the original asset file path.
  2. That reference doesn't match the case of the actual directory or file name.
  3. There is another reference to library/unity default assets which, in addition to being relative and case insensitive, also doesn't exist because Library/ is apparently a magic path in Unity. Rather than calling that out explicitly here, I've opted to just silently ignore nonexistent paths/files.

I wasn't able to test on Windows, which might have a problem with the case insensitive search.

PS: I also spotted a bug in save() but can't test the fix I included here. Let me know if that's a problem and I can remove it.

sparr commented 1 year ago

Lots of unrelated pip install errors in the test failures. Unclear if that's all of them.