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

Breaking Change: Fix objects with the same container path #172

Closed t-wy closed 1 year ago

t-wy commented 1 year ago

Addressing the issue #45, referenced PR #134 and AssetStudio's original implementation.

Reimplemented the array of KeyValuePair (multi-dict) structure in AssetStudio as a list-of-tuple structure to address the issue of multiple objects with the same container path when implemented as dict, such that all objects return the expected .container str value instead of None. The tuple ((path, obj)) may be changed to a list ([path, obj]), a dict ({"path": path, "obj": obj}), or a new class structure (.path = path, .obj = obj) if it is intended to be mutable.

Breaking Part: All .items() call to .container or .m_Container is no longer needed as it is an array instead of a dict. To avoid the compatibility issue, a list wrapper class with an .items() method that returns the list may be used in all container properties.

K0lb3 commented 1 year ago

Sorry for the late reply. I'm aware of the issue and refrained from fixing it because of the issue you mentioned - that it would be a fatal breaking change.

I "fixed" it in a test branch some time ago without breaking the normal usage pattern while still allowing it to pass through all keys and values. UnityPy@fsspec - UnityPy/files/SerializedFile.py

t-wy commented 1 year ago

Thanks for the reply. I see the concern, especially when it comes to the compatbility issues. Seems like the workaround wrapper provided is within my expectations. Looking forward to the release than :) (Meanwhile I can still take some monkey patches to handle my own usages :))

K0lb3 commented 1 year ago

implemented by #186