K0lb3 / UnityPy

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

UnityPy.load fails to load assets if Path is passed instead of string #194

Closed Artalus closed 11 months ago

Artalus commented 12 months ago

Bug There is a check in Environment constructor:

                if isinstance(arg, str):
                    if self.fs.isfile(arg):
                        ...

, which causes this code to fail to load a bundle file:

bundle = Path(sys.argv[1])
assert(bundle.is_file())
env = UnityPy.load(bundle)

The env object is created but is "empty". If I instead do UnityPy.load(str(bundle)), everything works as expected. The issue is probably not related to bundles specifically, and should be reproducible with any asset file.

UnityPy: 1.10.1

K0lb3 commented 11 months ago

The function expects either a str, bytes, or binaryio input, or a list of one of these types, and not Path. As you already noticed yourself, wrapping it in str fixes your problem.