K0lb3 / UnityPy

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

ObjectReader.dump_typetree() Throws: 'NoneType' object is not callable #262

Closed DavidESDR closed 2 weeks ago

DavidESDR commented 3 weeks ago

Code

object.dump_typetree();

Error

File "..\UnityPy\files\ObjectReader.py", line 193, in dump_typetree
    nodes = self.get_typetree(nodes)
TypeError: 'NoneType' object is not callable

Fix It seems to just be a typo. I changed get_typetree to get_typetree_nodes and it worked perfectly after testing.

def dump_typetree(self, nodes: list = None) -> str:
    self.reset()
    sb = []
    # Error here: "get_typetree is non-callable"
    nodes = self.get_typetree(nodes)
    # Should be:
    # nodes = self.get_typetree_nodes(nodes)
    TypeTreeHelper.read_typetree_str(sb, nodes, self)
    return "".join(sb)

Version UnityPy 1.10.17 Python 3.12.5

K0lb3 commented 2 weeks ago

Thanks for reporting the issue. You're right, looks like I forgot to update the function when I reworked this ages ago.