Closed khronii closed 1 year ago
You're right, m_IsArray is actually an int. Thanks for figuring out this issue, I will patch it in a bit.
Actually, m_IsArray is only an int for old Unity versions, it's a boolean for all other versions.
See
or as comparison
The simplification at https://github.com/K0lb3/UnityPy/blob/d1f9f9755be9447148219edefde7126e032d5c63/UnityPy/files/SerializedFile.py#L335 might actually be incorrect though.
Using AssetStudio says it is built with 2021.2.10f1
(doesn't sound that old and UnityPy parses it with *_blob variant) so maybe it's now int
again? Just guessing.
I don't think reverting it to int would be harmful by the way.
Writing it as int at the place you marked wouldn't work, but byte would. (int - 4 bytes, byte - 1 byte, boolean - 1 byte) And apparently, AssetStudio also made it work like that....looks like my browser was kinda weird displaying an old file.
Can you try the linked branch and see if it works for you?
Writing it as int at the place you marked wouldn't work, but byte would.
Seems like I mentioned that on a title and immediately forgot about it since github logs title change and there's no log that changed the title before I added a dot for a test.
Can you try the linked branch and see if it works for you?
After testing the original pip package, it looks like ignoring the fact it contains non-boolean values does not cause any crash. So I have to change the source code to spit out raw data again if I have to confirm your changes.
And something to mention : I did make my own homebrew patch directly on the source file
type = f"{reader.endian}hbbIIiii" #L350
writer.write_byte(node.m_IsArray) #L594
and that preserved the aforementioned data well. I should find out what this flag is for though.
I should find out what this flag is for though.
So, about the crash that caused by editing (nothing) via UnityPy, turns out that it was not related to this loss of data. It was because Unity checked CRC of the file (actually, the contents of BundleFile
) I was editing, and that CRC data was included in catalog.json
, under "m_ExtraDataString"
. It would be nice if UnityPy
can handle catalog.json
, too. Should I open another issue about this?
I'm actually already working on a catalog parser and am more or less done with it. I will add it at the weekend to UnityPy.tools.
I'm actually already working on a catalog parser and am more or less done with it. I will add it at the weekend to UnityPy.tools.
Sounds great!
I just found out that you bumped the version to 1.9.18 and confirmed #144 does fix this issue. Thank you for working on this!
I'm actually already working on a catalog parser and am more or less done with it. I will add it at the weekend to UnityPy.tools.
How can I find the parser in UnityPy.tools?
https://github.com/K0lb3/UnityPy/blob/d1f9f9755be9447148219edefde7126e032d5c63/UnityPy/files/SerializedFile.py#L594
While I was investigating why repacking bundle fails even without modification, I found out that node.m_IsArray is sometimes not 0 or 1 but a multiple of 2 (or so I guess). So far I found 2,4 and 8 can exist.
(Sorry for the poorly edited image)