Skip to content

Commit 3dcef30

Browse files
committed
docs: README - improve objects section, add details for object modification
1 parent 40d1f08 commit 3dcef30

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@
99
A Unity asset extractor for Python based on [AssetStudio](https://github.com/Perfare/AssetStudio).
1010

1111
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-
```
2412

2513
If you need advice or if you want to talk about (game) data-mining,
2614
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
209197

210198
Objects \([ObjectReader class](UnityPy/files/ObjectReader.py)\) contain the _actual_ files, e.g., textures, text files, meshes, settings, ...
211199

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+
```
213217

214218
## Important Object Types
215219

0 commit comments

Comments
 (0)