UnityPy.load fails to load assets if Path is passed instead of string
Artalus opened this issue · comments
Artalus commented
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
Rudolf Kolbe commented
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.