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
Visual C++ Redistributable is required for the brotli dependency.
71
72
In case a new(ish) Python version is used, it can happen that the C-dependencies of UnityPy might not be precompiled for this version.
72
73
In such cases the user either has to report this as issue or follow the steps of [this issue](https://github.com/K0lb3/UnityPy/issues/223) to compile it oneself.
73
-
Another option for the user is downgrading Python to the latest version supported by UnityPy. For this see the python version badge at the top of the README.
74
+
Another option for the user is downgrading Python to the latest version supported by UnityPy. For this see the Python version badge at the top of the README.
74
75
75
76
### Crash without warning/error
76
77
77
-
The C-implementation of the typetree reader can directly crash python.
78
+
The C-implementation of the typetree reader can directly crash Python.
78
79
In case this happens, the usage of the C-typetree reader can be disabled by adding these two lines to your main file.
79
80
80
81
```python
@@ -90,7 +91,7 @@ The following is a simple example.
You probably have to read [Important Classes](#important-classes)
135
136
and [Important Object Types](#important-object-types) to understand how it works.
136
137
137
-
People with slightly advanced python skills should look at [UnityPy/tools/extractor.py](UnityPy/tools/extractor.py) for a more advanced example.
138
+
People with slightly advanced Python skills should look at [UnityPy/tools/extractor.py](UnityPy/tools/extractor.py) for a more advanced example.
138
139
It can also be used as a general template or as an importable tool.
139
140
140
141
### Setting the decryption key for Unity CN's AssetBundle encryption
141
142
142
-
The chinese version of Unity has its own inbuild option to encrypt AssetBundles/BundleFiles. As it's a feature of Unity itself, and not a game specific protection, it is included in UnityPy as well.
143
-
To enable encryption simply use `UnityPy.set_assetbundle_decrypt_key(key)`, with key being the value that the game that loads the budles passes to `AssetBundle.SetAssetBundleDecryptKey`.
143
+
The Chinese version of Unity has its own builtin option to encrypt AssetBundles/BundleFiles. As it's a feature of Unity itself, and not a game specific protection, it is included in UnityPy as well.
144
+
To enable encryption simply use `UnityPy.set_assetbundle_decrypt_key(key)`, with key being the value that the game that loads the bundles passes to `AssetBundle.SetAssetBundleDecryptKey`.
144
145
145
146
## Important Classes
146
147
147
-
### [Environment](UnityPy/environment.py)
148
+
### Environment
148
149
149
-
Environment loads and parses the given files.
150
+
[Environment](UnityPy/environment.py) loads and parses the given files.
150
151
It can be initialized via:
151
152
152
153
- a file path - apk files can be loaded as well
153
154
- a folder path - loads all files in that folder (bad idea for folders with a lot of files)
154
-
- a stream - e.g., io.BytesIO, file stream,...
155
+
- a stream - e.g., `io.BytesIO`, file stream,...
155
156
- a bytes object - will be loaded into a stream
156
157
157
158
UnityPy can detect if the file is a WebFile, BundleFile, Asset, or APK.
@@ -183,26 +184,26 @@ with open(dst, "wb") as f:
183
184
f.write(env.file.save())
184
185
```
185
186
186
-
### [Asset](UnityPy/files/SerializedFile.py)
187
+
### Asset
187
188
188
-
Assets are a container that contains multiple objects.
189
+
Assets \([SerializedFile class](UnityPy/files/SerializedFile.py)\)are a container that contains multiple objects.
189
190
One of these objects can be an AssetBundle, which contains a file path for some of the objects in the same asset.
190
191
191
192
All objects can be found in the `.objects` dict - `{ID : object}`.
192
193
193
194
The objects with a file path can be found in the `.container` dict - `{path : object}`.
194
195
195
-
### [Object](UnityPy/files/ObjectReader.py)
196
+
### Object
196
197
197
-
Objects contain the _actual_ files, e.g., textures, text files, meshes, settings, ...
198
+
Objects \([ObjectReader class](UnityPy/files/ObjectReader.py)\)contain the _actual_ files, e.g., textures, text files, meshes, settings, ...
198
199
199
200
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
201
201
202
## Important Object Types
202
203
203
-
All object types can be found in [UnityPy/classes](UnityPy/classes/).
204
+
Now UnityPy uses [auto generated classes](UnityPy/classes/generated.py). You can search for a specific classes in the module `UnityPy.classes`.
204
205
205
-
### [Texture2D](UnityPy/classes/Texture2D.py)
206
+
### Texture2D
206
207
207
208
-`.m_Name`
208
209
-`.image` converts the texture into a `PIL.Image`
@@ -226,7 +227,7 @@ for obj in env.objects:
226
227
data.save()
227
228
```
228
229
229
-
### [Sprite](UnityPy/classes/Sprite.py)
230
+
### Sprite
230
231
231
232
Sprites are part of a texture and can have a separate alpha-image as well.
232
233
Unlike most other extractors (including AssetStudio), UnityPy merges those two images by itself.
MonoBehaviour assets are usually used to save the class instances with their values.
278
279
The structure/typetree for these classes might not be contained in the asset files.
@@ -312,7 +313,7 @@ for obj in env.objects:
312
313
UnityPy can generate the typetrees of MonoBehaviours from the game assemblies using an optional package, ``TypeTreeGeneratorAPI``, which has to be installed via pip.
313
314
UnityPy will automatically try to generate the typetree of MonoBehaviours if the typetree is missing in the assets and ``env.typetree_generator`` is set.
314
315
315
-
```py
316
+
```python
316
317
import UnityPy
317
318
from UnityPy.helpers.TypeTreeGenerator import TypeTreeGenerator
318
319
@@ -340,7 +341,7 @@ for obj in objects:
340
341
```
341
342
342
343
343
-
### [AudioClip](UnityPy/classes/AudioClip.py)
344
+
### AudioClip
344
345
345
346
-`.samples` - `{sample-name : sample-data}`
346
347
@@ -354,7 +355,9 @@ for name, data in clip.samples.items():
354
355
f.write(data)
355
356
```
356
357
357
-
### [Font](UnityPy/classes/Font.py)
358
+
### Font
359
+
360
+
**Export**
358
361
359
362
```python
360
363
if obj.type.name =="Font":
@@ -368,14 +371,14 @@ if obj.type.name == "Font":
368
371
f.write(font.m_FontData)
369
372
```
370
373
371
-
### [Mesh](UnityPy/classes/Mesh.py)
374
+
### Mesh
372
375
373
376
-`.export()` - mesh exported as .obj (str)
374
377
375
378
The mesh will be converted to the Wavefront .obj file format.
376
379
377
380
```python
378
-
mesh: Mesh
381
+
mesh: Mesh
379
382
withopen(f"{mesh.m_Name}.obj", "wt", newline="") as f:
380
383
# newline = "" is important
381
384
f.write(mesh.export())
@@ -390,7 +393,7 @@ ALPHA-VERSION
390
393
The mesh and materials will be in the Wavefront formats.
391
394
392
395
```python
393
-
mesh_renderer: Renderer
396
+
mesh_renderer: Renderer
394
397
export_dir: str
395
398
396
399
if mesh_renderer.m_GameObject:
@@ -400,7 +403,7 @@ if mesh_renderer.m_GameObject:
UnityPy uses [fsspec](https://github.com/fsspec/filesystem_spec) under the hood to manage all filesystem interactions.
429
432
This allows using various different types of filesystems without having to change UnityPy's code.
430
433
It also means that you can use your own custom filesystem to e.g. handle indirection via catalog files, load assets on demand from a server, or decrypt files.
431
434
432
435
Following methods of the filesystem have to be implemented for using it in UnityPy.
433
436
434
-
- sep (not a function, just the seperator as character)
437
+
- sep (not a function, just the separator as character)
435
438
- isfile(self, path: str) -> bool
436
439
- isdir(self, path: str) -> bool
437
440
- exists(self, path: str, \*\*kwargs) -> bool
@@ -444,11 +447,10 @@ Following methods of the filesystem have to be implemented for using it in Unity
444
447
First of all,
445
448
thanks a lot to all contributors of UnityPy and all of its users.
446
449
447
-
Also,
448
-
many thanks to:
450
+
Also, many thanks to:
449
451
450
452
-[Perfare](https://github.com/Perfare) for creating and maintaining and every contributor of [AssetStudio](https://github.com/Perfare/AssetStudio)
451
453
-[ds5678](https://github.com/ds5678) for the [TypeTreeDumps](https://github.com/AssetRipper/TypeTreeDumps) and the [custom minimal Tpk format](https://github.com/AssetRipper/Tpk)
452
454
-[Razmoth](https://github.com/Razmoth) for figuring out and sharing Unity CN's AssetBundle decryption ([src](https://github.com/Razmoth/PGRStudio)).
453
455
-[nesrak1](https://github.com/nesrak1) for figuring out the [Switch texture swizzling](https://github.com/nesrak1/UABEA/blob/master/TexturePlugin/Texture2DSwitchDeswizzler.cs)
454
-
- xiop_13690 (discord) for figuring out unsolved issues of the ManagedReferencesRegistry
456
+
- xiop_13690 (discord) for figuring out unsolved issues of the ManagedReferencesRegistry
0 commit comments