Skip to content

Commit 9866fd0

Browse files
committed
docs: README - format and quote blocks
1 parent e1d9b04 commit 9866fd0

1 file changed

Lines changed: 39 additions & 18 deletions

File tree

README.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,24 @@ feel free to join the [UnityPy Discord](https://discord.gg/C6txv7M).
1616
If you're using UnityPy for a commercial project,
1717
a donation to a charitable cause or a sponsorship of this project is expected.
1818

19-
**As UnityPy is still in active development, breaking changes can happen.**
20-
These changes are usually limited to minor versions (x.y) and not to patch versions (x.y.z).
21-
So in case that you don't want to actively maintain your project,
22-
make sure to make a note of the used UnityPy version in your README or add a check in your code.
23-
e.g.
19+
> [!NOTE]
20+
> **As UnityPy is still in active development, breaking changes can happen.**
21+
> These changes are usually limited to minor versions (x.y) and not to patch versions (x.y.z).
22+
>
23+
> <details>
24+
> <summary>In case you don't want to actively maintain your project...</summary>
25+
>
26+
> Make a note of the used UnityPy version in your README or add a check in your code.
27+
>
28+
> ```python
29+
> if UnityPy.__version__ != '1.9.6':
30+
> raise ImportError("Invalid UnityPy version detected. Please use version 1.9.6")
31+
> ```
32+
>
33+
> You can also pin the version in your `requirements.txt` or `pyproject.toml` file, which is the best practice.
34+
>
35+
> </details>
2436
25-
```python
26-
if UnityPy.__version__ != '1.9.6':
27-
raise ImportError("Invalid UnityPy version detected. Please use version 1.9.6")
28-
```
2937
3038
1. [Installation](#installation)
3139
2. [Example](#example)
@@ -208,12 +216,17 @@ The objects with a file path can be found in the `.container` dict - `{path : ob
208216
209217
Objects \([ObjectReader class](UnityPy/files/ObjectReader.py)\) contain the _actual_ files, e.g., textures, text files, meshes, settings, ...
210218
211-
To acquire the actual data of an object it has to be parsed first.
219+
> [!IMPORTANT]
220+
>
221+
> To acquire the actual data of an object it has to be parsed first.
212222
This happens via the parse functions mentioned below.
213223
This isn't done automatically to save time as only a small part of the objects are usually of interest.
214-
Serialized objects can be set with raw data using `.set_raw_data(data)` or modified with `.save()` function, if supported.
215224
216-
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.
225+
> [!TIP]
226+
>
227+
> For object types with attribute `.m_Name` you can use `.peek_name()` to only read the name of the parsed object without parsing it completely, which is way faster.
228+
229+
Serialized objects can be set with raw data using `.set_raw_data(data)` or modified with `.save()` function, if supported.
217230
218231
There are two general parsing functions, ``.parse_as_object()`` and ``.parse_as_dict()``.
219232
``parse_as_dict`` parses the object data into a dict.
@@ -269,6 +282,7 @@ Now UnityPy uses [auto generated classes](UnityPy/classes/generated.py) with som
269282
270283
```python
271284
from PIL import Image
285+
272286
for obj in env.objects:
273287
if obj.type.name == "Texture2D":
274288
# export texture
@@ -352,7 +366,7 @@ for obj in env.objects:
352366
tree = obj.parse_as_dict()
353367
fp = os.path.join(extract_dir, f"{tree['m_Name']}.json")
354368
with open(fp, "wt", encoding = "utf8") as f:
355-
json.dump(tree, f, ensure_ascii = False, indent = 4)
369+
json.dump(tree, f, ensure_ascii=False, indent=4)
356370
357371
# edit
358372
tree = obj.parse_as_dict()
@@ -431,14 +445,16 @@ The mesh will be converted to the Wavefront .obj file format.
431445
432446
```python
433447
mesh: Mesh
434-
with open(f"{mesh.m_Name}.obj", "wt", newline = "") as f:
448+
with open(f"{mesh.m_Name}.obj", "wt", newline="") as f:
435449
# newline = "" is important
436450
f.write(mesh.export())
437451
```
438452
439453
### Renderer, MeshRenderer, SkinnedMeshRenderer
440454
441-
ALPHA-VERSION
455+
> [!WARNING]
456+
>
457+
> This feature is in alpha version.
442458
443459
- `.export(export_dir)` - exports the associated mesh, materials, and textures into the given directory
444460
@@ -458,7 +474,9 @@ mesh_renderer.export(export_dir)
458474
459475
### Texture2DArray
460476
461-
WARNING - not well tested
477+
> [!WARNING]
478+
>
479+
> This feature isn't well tested.
462480
463481
- `.m_Name`
464482
- `.image` converts the texture2darray into a `PIL.Image`
@@ -490,6 +508,7 @@ To enable encryption simply use the code as follow, with `key` being the value t
490508
491509
```python
492510
import UnityPy
511+
493512
UnityPy.set_assetbundle_decrypt_key(key)
494513
```
495514
@@ -499,6 +518,7 @@ In case UnityPy failed to detect the Unity version of the game assets, you can s
499518
500519
```python
501520
import UnityPy.config
521+
502522
UnityPy.config.FALLBACK_UNITY_VERSION = "2.5.0f5"
503523
```
504524
@@ -508,6 +528,7 @@ The [C-implementation](UnityPyBoost/) of typetree reader can boost the parsing o
508528
509529
```python
510530
from UnityPy.helpers import TypeTreeHelper
531+
511532
TypeTreeHelper.read_typetree_boost = False
512533
```
513534
@@ -517,9 +538,9 @@ Some game assets have non-standard compression/decompression algorithm applied o
517538
518539
```python
519540
from UnityPy.enums.BundleFile import CompressionFlags
520-
flag = CompressionFlags.LZHAM
521-
522541
from UnityPy.helpers import CompressionHelper
542+
543+
flag = CompressionFlags.LZHAM
523544
CompressionHelper.COMPRESSION_MAP[flag] = custom_compress
524545
CompressionHelper.DECOMPRESSION_MAP[flag] = custom_decompress
525546
```

0 commit comments

Comments
 (0)