You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import UnityPy
env = UnityPy.load("level0")
for obj in env.objects:
if obj.type.name == "MonoBehaviour":
if obj.serialized_type.node:
print(obj.read_typetree())
Code 2
import json
import UnityPy
with open("typetree.json", "r") as f:
typetree_data = json.load(f)
env = UnityPy.load("level0")
for obj in env.objects:
if obj.type.name == "MonoBehaviour":
monobehaviour = obj.read()
script = monobehaviour.m_Script.read()
if obj.serialized_type.nodes:
tree = obj.read_typetree()
else:
if script.m_Namespace == "":
typetree = typetree_data[script.m_AssemblyName][script.m_ClassName]
else:
typetree = typetree_data[script.m_AssemblyName][
f"{script.m_Namespace}.{script.m_ClassName}"
]
tree = obj.read_typetree(typetree)
print(tree)
Error
Code 1 is the one I used in the past to extract Monobehaviour from a .bundle file with a built-in typetree.
If you run the code above, it won't produce any output, probably because it doesn't have a typetree built in.
Code 2 results in an error as shown below.
Traceback (most recent call last):
File "c:\Program Files (x86)\Steam\steamapps\common\Muck\Muck_Data\main.py", line 10, in <module>
monobehaviour = obj.read()
^^^^^^^^^^
File "C:\Users\USER\AppData\Roaming\Python\Python312\site-packages\UnityPy\files\ObjectReader.py", line 174, in read
obj = self.read_typetree(wrap=True, check_read=check_read)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\AppData\Roaming\Python\Python312\site-packages\UnityPy\files\ObjectReader.py", line 210, in read_typetree
ret = TypeTreeHelper.read_typetree(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\AppData\Roaming\Python\Python312\site-packages\UnityPy\helpers\TypeTreeHelper.py", line 149, in read_typetree
raise ValueError(
ValueError: Expected to read 52 bytes, but only read 32 bytes
if I edit obj.read() to obj.read(check_read=False), The error message will be different, as shown below.
Traceback (most recent call last):
File "c:\Program Files (x86)\Steam\steamapps\common\Muck\Muck_Data\main.py", line 11, in <module>
script = monobehaviour.m_Script.read()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\AppData\Roaming\Python\Python312\site-packages\UnityPy\classes\PPtr.py", line 37, in read
return self.deref_parse_as_object()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\AppData\Roaming\Python\Python312\site-packages\UnityPy\classes\PPtr.py", line 92, in deref_parse_as_object
return self.deref(assetsfile).parse_as_object()
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\AppData\Roaming\Python\Python312\site-packages\UnityPy\classes\PPtr.py", line 81, in deref
cab = env.find_file(external_clean_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\AppData\Roaming\Python\Python312\site-packages\UnityPy\environment.py", line 320, in find_file
raise FileNotFoundError(f"File {name} not found in {self.path}")
FileNotFoundError: File unity_builtin_extra not found in C:\Program Files (x86)\Steam\steamapps\common\Muck\Muck_Data
If I move the unity_builtin_extra file to the Muck_Data folder, I get the same error message.
Bug It shows ValueError: Expected to read 52 bytes, but only read 32 bytes FileNotFoundError: File unity_builtin_extra not found in C:\Program Files (x86)\Steam\steamapps\common\Muck\Muck_Data To Reproduce
My goal is to modify and import the TextMeshProUGUI asset from the assets in level0.
Can you tell how to extract the Typetree correctly, how to load it and how to extract the Monobehaviour from the .asset file using the Typetree json?
Thank you for your hard work.
The text was updated successfully, but these errors were encountered:
Game
Muck
(Steam free game. Muck)
Files I used
Code
Code 1
Code 2
Error
Code 1 is the one I used in the past to extract Monobehaviour from a .bundle file with a built-in typetree.
If you run the code above, it won't produce any output, probably because it doesn't have a typetree built in.
Code 2 results in an error as shown below.
if I edit obj.read() to obj.read(check_read=False), The error message will be different, as shown below.
If I move the unity_builtin_extra file to the Muck_Data folder, I get the same error message.
Bug
It shows ValueError: Expected to read 52 bytes, but only read 32 bytes
FileNotFoundError: File unity_builtin_extra not found in C:\Program Files (x86)\Steam\steamapps\common\Muck\Muck_Data
To Reproduce
My goal is to modify and import the TextMeshProUGUI asset from the assets in level0.
Can you tell how to extract the Typetree correctly, how to load it and how to extract the Monobehaviour from the .asset file using the Typetree json?
Thank you for your hard work.
The text was updated successfully, but these errors were encountered: