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

AttributeError: 'NodeHelper' object has no attribute 'name' #197

Closed 28598519a closed 6 months ago

28598519a commented 11 months ago

Code

Error

To Reproduce

martinwang2002 commented 8 months ago

Use

if hasattr(data, "name"):
      obj_name = getattr(data, “name”)

Since not every stuff has name.

28598519a commented 6 months ago

Use

if hasattr(data, "name"):
      obj_name = getattr(data, “name”)

Since not every stuff has name.

image

and got

image

but in the first comment you can see it should has name AssetBundleManifest. Directly print shows NodeHelper has the key "name" with -> "AssetBundleManifest"

I will give you the sample file, unzip and load the file inside. FileToRead.zip

K0lb3 commented 6 months ago

m_Name has to be used instead of name.

AssetBundleManifest is not hardcorded and get instead parsed via its typetree, which produces a class interface (NodeHelper) over a dict.

As the name and m_Name can be valid fields, I didn't add a wrapper for NodeHelper to prevent blocking access to a potential name field.