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

.save_typetree() MonoBehaviour function not working. #231

Closed AcidicPeridot closed 3 months ago

AcidicPeridot commented 3 months ago

Code

for obj in data.objects:
    if obj.type.name == "MonoBehaviour" and obj.read_typetree()["m_Name"] == item.replace(".json", ""):
        tree = script
        obj.save_typetree(tree)
        continue

Error No error.

Bug Here's a script that helps me export/import event scripts from a mobile game. This exact code has worked in the past, but I've adjusted some thing in my ecosystem of scripts for this particular game to save me quite a bit of time, but now the script saving part doesn't want to cooperate it seems. I have a dictionary grabbed from a JSON file on disk, saved as "script", which is a modified version of the MonoBehaviour object's typetree called in the asset bundle. The asset opens fine, the typetree reads fine (all the data is correct from obj.read_typetree) and it can save the asset fine, obj.save_typetree just doesn't do anything.

To Reproduce