|
9 | 9 | A Unity asset extractor for Python based on [AssetStudio](https://github.com/Perfare/AssetStudio). |
10 | 10 |
|
11 | 11 | Next to extraction, UnityPy also supports editing Unity assets. |
12 | | -Via the typetree structure all object types can be edited in their native forms. |
13 | | - |
14 | | -```python |
15 | | -# modification via dict: |
16 | | - raw_dict = obj.read_typetree() |
17 | | - # modify raw dict |
18 | | - obj.save_typetree(raw_dict) |
19 | | -# modification via parsed class |
20 | | - instance = obj.read() |
21 | | - # modify instance |
22 | | - obj.save(instance) |
23 | | -``` |
24 | 12 |
|
25 | 13 | If you need advice or if you want to talk about (game) data-mining, |
26 | 14 | feel free to join the [UnityPy Discord](https://discord.gg/C6txv7M). |
@@ -209,7 +197,23 @@ The objects with a file path can be found in the `.container` dict - `{path : ob |
209 | 197 |
|
210 | 198 | Objects \([ObjectReader class](UnityPy/files/ObjectReader.py)\) contain the _actual_ files, e.g., textures, text files, meshes, settings, ... |
211 | 199 |
|
212 | | -To acquire the actual data of an object it has to be read first. This happens via the `.read()` function. This isn't done automatically to save time because only a small part of the objects are of interest. Serialized objects can be set with raw data using `.set_raw_data(data)` or modified with `.save()` function, if supported. |
| 200 | +To acquire the actual data of an object reader, you must first _read_ it. This happens via the `.read()` function. |
| 201 | +To save time, object reading _isn't_ done automatically because usually only a small part of the objects are of interest. |
| 202 | + |
| 203 | +Via two ways you can modify the data of an object: |
| 204 | + |
| 205 | +1. Typetree structure based - all object types can be edited in their native forms. |
| 206 | + ```python |
| 207 | + raw_dict = obj.read_typetree() # get typetree dict |
| 208 | + ... # your code to modify the raw dict |
| 209 | + obj.save_typetree(raw_dict) |
| 210 | + ``` |
| 211 | +2. Parsed class based - some serialized object types have a parsed class representation which may expose mutable attributes. |
| 212 | + ```python |
| 213 | + instance = obj.read() # get actual object |
| 214 | + ... # your code to modify it |
| 215 | + instance.save() |
| 216 | + ``` |
213 | 217 |
|
214 | 218 | ## Important Object Types |
215 | 219 |
|
|
0 commit comments