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

TextAsset no longer has a bytes script in 1.20 #269

Closed thesadru closed 1 week ago

thesadru commented 1 week ago

I cannot get a bytes version of m_Script anymore and there doesn't seem to be a reliable way to encode the data back into bytes.

K0lb3 commented 1 week ago

That is indirectly on purpose, as this is how it's defined in Unity's own typetree structure. The only problem with it is that the string class in C++ and C# is closer to python's bytes class. As bytes are a bit annoying to use, it still maps to str.

There is a reliable way to get the encoded data though, which I also wrote into the updated readme.

str.encode("utf-8", "surrogateescape"))

thesadru commented 1 week ago

I see. I assume the issue with encoding must've been on my side. Would it be possible to delete the line referencing a script attribute in the readme?

K0lb3 commented 1 week ago

Oh, thanks, I missed the .script part.