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
dest = os.path.join(destination_folder, *path.split("/"))
122
122
# make sure that the dir of that path exists
@@ -187,7 +187,51 @@ The objects with a file path can be found in the `.container` dict - `{path : ob
187
187
188
188
Objects \([ObjectReader class](UnityPy/files/ObjectReader.py)\) contain the _actual_ files, e.g., textures, text files, meshes, settings, ...
189
189
190
-
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.
190
+
To acquire the actual data of an object it has to be parsed first.
191
+
This happens via the parse functions mentioned below.
192
+
This isn't done automatically to save time as only a small part of the objects are usually of interest.
193
+
Serialized objects can be set with raw data using `.set_raw_data(data)` or modified with `.save()` function, if supported.
194
+
195
+
For object types with ``m_Name`` you can use ``.peek_name()`` to only read the name of the parsed object without parsing it completely, which is way faster.
196
+
197
+
There are two general parsing functions, ``.parse_as_object()`` and ``.parse_as_dict()``.
198
+
``parse_as_dict`` parses the object data into a dict.
199
+
``parse_as_object`` parses the object data into a class. If the class is a Unity class, it's stub class from ``UnityPy.classes(.generated)`` will be used, if it's an unknown one, then it will be parsed into an ``UnknownObject``, which simply acts as interface for the otherwise parsed dict.
200
+
Some special classes, namely those below, have additional handlers added to their class for easier interaction with them.
201
+
202
+
The ``.patch(item)`` function can be used on all object (readers) to replace their data with the changed item, which has to be either a dict or of the class the object represents.
203
+
204
+
#### Example
205
+
206
+
```py
207
+
for obj in env.objects:
208
+
if obj.type.name =="the type you want":
209
+
if obj.peek_name() !="the specific object you want":
210
+
continue
211
+
# parsing
212
+
instance = obj.parse_as_object()
213
+
dic = obj.parse_as_dict()
214
+
215
+
# modifying
216
+
instance.m_Name ="new name"
217
+
dic["m_Name"] ="new name"
218
+
219
+
# saving
220
+
obj.patch(instance)
221
+
obj.patch(dic)
222
+
```
223
+
224
+
#### Legacy
225
+
226
+
Following functions are legacy functions that will be removed in the future when major version 2 hits.
227
+
The modern versions are equivalent to them and have a more correct type hints.
0 commit comments