Skip to content

Commit 855db68

Browse files
committed
chore(release.yml): update cibuildwheel to 3.3
1 parent 578a1b2 commit 855db68

6 files changed

Lines changed: 80 additions & 85 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ jobs:
1919

2020
- name: Build sdist
2121
run: pipx run build --sdist
22-
22+
2323
- name: Install sdist
2424
run: pip install dist/*.tar.gz
2525

2626
- uses: actions/upload-artifact@v4
2727
with:
2828
name: "sdist"
2929
path: dist/*.tar.gz
30-
30+
3131
build_wheels:
3232
name: Build wheels on ${{ matrix.os }}
3333
runs-on: ${{ matrix.os }}
@@ -41,19 +41,19 @@ jobs:
4141
- uses: actions/checkout@v4
4242
with:
4343
submodules: recursive
44-
44+
4545
- name: Build wheels
46-
uses: joerick/cibuildwheel@v2.21.2
46+
uses: joerick/cibuildwheel@v3.3
4747
env:
4848
CIBW_TEST_SKIP: "*"
4949
CIBW_SKIP: "pp*"
50-
50+
5151
- uses: actions/upload-artifact@v4
5252
with:
5353
name: "${{ matrix.os }}"
5454
path: ./wheelhouse/*.whl
5555
retention-days: 1
56-
56+
5757
build_manylinux_wheels_ubuntu:
5858
name: Build manylinux wheels on ubuntu-latest
5959
runs-on: ubuntu-latest
@@ -70,7 +70,7 @@ jobs:
7070
platforms: all
7171

7272
- name: Build wheels
73-
uses: joerick/cibuildwheel@v2.21.2
73+
uses: joerick/cibuildwheel@v3.3
7474
env:
7575
CIBW_TEST_SKIP: "*"
7676
CIBW_SKIP: "pp* *-musllinux*"
@@ -97,11 +97,11 @@ jobs:
9797
platforms: all
9898

9999
- name: Build wheels
100-
uses: joerick/cibuildwheel@v2.21.2
100+
uses: joerick/cibuildwheel@v3.3
101101
env:
102102
CIBW_TEST_SKIP: "*"
103103
CIBW_SKIP: "pp* *-manylinux*"
104-
# fmod requires:
104+
# fmod requires:
105105
# default via musl: -exclude flag
106106
# libdl.so.2 => /lib/ld-musl-x86_64.so.1 (0x7faeb127d000)
107107
# librt.so.1 => /lib/ld-musl-x86_64.so.1 (0x7faeb127d000)

UnityPy/export/MeshRendererExporter.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class Renderer(Renderer):
2525
def get_mesh(meshR: Renderer) -> Optional[Mesh]:
2626
if isinstance(meshR, SkinnedMeshRenderer):
2727
if meshR.m_Mesh:
28-
return meshR.m_Mesh.read()
28+
return meshR.m_Mesh.deref_parse_as_object()
2929
else:
30-
m_GameObject = meshR.m_GameObject.read()
30+
m_GameObject = meshR.m_GameObject.deref_parse_as_object()
3131
for comp in m_GameObject.m_Component:
3232
if isinstance(comp, tuple):
3333
pptr = comp[1]
@@ -39,9 +39,9 @@ def get_mesh(meshR: Renderer) -> Optional[Mesh]:
3939
if not obj:
4040
continue
4141
if obj.type.name == "MeshFilter":
42-
filter: MeshFilter = pptr.read()
42+
filter: MeshFilter = pptr.deref_parse_as_object()
4343
if filter.m_Mesh:
44-
return filter.m_Mesh.read()
44+
return filter.m_Mesh.deref_parse_as_object()
4545
return None
4646

4747

@@ -66,7 +66,7 @@ def export_mesh_renderer(renderer: Renderer, export_dir: str) -> None:
6666
continue
6767
matPtr: Optional[PPtr[Material]] = renderer.m_Materials[i - firstSubMesh]
6868
if matPtr:
69-
mat: Material = matPtr.read()
69+
mat: Material = matPtr.deref_parse_as_object()
7070
else:
7171
material_names.append(None)
7272
continue
@@ -79,10 +79,10 @@ def export_mesh_renderer(renderer: Renderer, export_dir: str) -> None:
7979
if not isinstance(key, str):
8080
# FastPropertyName
8181
key = key.name
82-
tex: Texture2D = texEnv.m_Texture.read()
82+
tex: Texture2D = texEnv.m_Texture.deref_parse_as_object()
8383
texName = f"{tex.m_Name if tex.m_Name else key}.png"
8484
with env.fs.open(env.fs.sep.join([export_dir, texName]), "wb") as f:
85-
tex.read().image.save(f)
85+
tex.image.save(f)
8686

8787
# save .obj
8888
with env.fs.open(
@@ -172,7 +172,7 @@ def properties_to_dict(properties):
172172
# FastPropertyName
173173
key = key.name
174174

175-
tex: Texture2D = texEnv.m_Texture.read()
175+
tex: Texture2D = texEnv.m_Texture.deref_parse_as_object()
176176
texName = f"{tex.m_Name if tex.m_Name else key}.png"
177177
if key == "_MainTex":
178178
sb.append(f"map_Kd {texName}")

UnityPy/export/SpriteHelper.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,30 @@ def get_image(sprite: Sprite, texture: PPtr[Texture2D], alpha_texture: Optional[
4747
if alpha_texture:
4848
cache_id = (texture.path_id, alpha_texture.path_id)
4949
if cache_id not in cache:
50-
original_image = get_image_from_texture2d(texture.read(), False)
51-
alpha_image = get_image_from_texture2d(alpha_texture.read(), False)
50+
original_image = get_image_from_texture2d(texture.deref_parse_as_object(), False)
51+
alpha_image = get_image_from_texture2d(alpha_texture.deref_parse_as_object(), False)
5252
original_image = Image.merge("RGBA", (*original_image.split()[:3], alpha_image.split()[0]))
5353
cache[cache_id] = original_image
5454
else:
5555
cache_id = texture.path_id
5656
if cache_id not in cache:
57-
original_image = get_image_from_texture2d(texture.read(), False)
57+
original_image = get_image_from_texture2d(texture.deref_parse_as_object(), False)
5858
cache[cache_id] = original_image
5959
return cache[cache_id]
6060

6161

6262
def get_image_from_sprite(m_Sprite: Sprite) -> Image.Image:
6363
atlas = None
6464
if m_Sprite.m_SpriteAtlas:
65-
atlas = m_Sprite.m_SpriteAtlas.read()
65+
atlas = m_Sprite.m_SpriteAtlas.deref_parse_as_object()
6666
elif m_Sprite.m_AtlasTags:
6767
# looks like the direct pointer is empty, let's try to find the Atlas via its name
6868
assert m_Sprite.assets_file, "Sprite assets file is not set!"
6969
for obj in m_Sprite.assets_file.objects.values():
7070
if obj.type == ClassIDType.SpriteAtlas:
71-
atlas = obj.read()
72-
if atlas.m_Name == m_Sprite.m_AtlasTags[0]:
71+
name = obj.peek_name()
72+
if name == m_Sprite.m_AtlasTags[0]:
73+
atlas = obj.parse_as_object()
7374
break
7475
atlas = None
7576

UnityPy/files/SerializedFile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def __init__(self, reader: EndianBinaryReader, parent=None, name=None, **kwargs)
315315
# read the asset_bundles to get the containers
316316
for obj in self.objects.values():
317317
if obj.type == ClassIDType.AssetBundle:
318-
self.assetbundle = obj.read()
318+
self.assetbundle = obj.parse_as_object()
319319
self._container = ContainerHelper(self.assetbundle)
320320
break
321321
else:

UnityPy/tools/extractor.py

Lines changed: 42 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
Texture2D,
2020
)
2121
from UnityPy.enums.ClassIDType import ClassIDType
22-
from UnityPy.files import SerializedFile
22+
from UnityPy.files import ObjectReader, SerializedFile
2323

2424

2525
def export_obj(
26-
obj: Union[Object, PPtr],
27-
fp: Path,
26+
obj: Union[ObjectReader, PPtr],
27+
fp: str,
2828
append_name: bool = False,
2929
append_path_id: bool = False,
3030
export_unknown_as_typetree: bool = False,
@@ -53,25 +53,29 @@ def export_obj(
5353
return []
5454

5555
# set filepath
56-
obj = obj.read()
56+
if isinstance(obj, PPtr):
57+
obj = obj.deref()
58+
59+
instance = obj.parse_as_object()
5760

5861
# a filter that returned True during an earlier extract_assets check can return False now with more info from read()
59-
if asset_filter and not asset_filter(obj):
62+
if asset_filter and not asset_filter(instance):
6063
return []
6164

6265
if append_name:
66+
name = getattr(instance, "m_Name", obj.type.name)
6367
fp = os.path.join(
6468
fp,
65-
obj.m_Name if getattr(obj, "m_Name") else obj.object_reader.type.name, # noqa: B009
69+
name,
6670
)
6771

6872
fp, extension = os.path.splitext(fp)
6973

7074
if append_path_id:
71-
fp = f"{fp}_{obj.object_reader.path_id}"
75+
fp = f"{fp}_{obj.m_PathID}"
7276

7377
# export
74-
return export_func(obj, fp, extension)
78+
return export_func(instance, fp, extension)
7579

7680

7781
def extract_assets(
@@ -193,40 +197,28 @@ def exportShader(obj: Shader, fp: str, extension=".txt") -> List[Tuple[Serialize
193197
return [(obj.assets_file, obj.object_reader.path_id)]
194198

195199

196-
def exportMonoBehaviour(
197-
obj: Union[MonoBehaviour, Object], fp: str, extension: str = ""
198-
) -> List[Tuple[SerializedFile, int]]:
200+
def exportMonoBehaviour(obj: ObjectReader, fp: str, extension: str = "") -> List[Tuple[SerializedFile, int]]:
199201
export = None
200202

201-
if obj.object_reader.serialized_type.node:
202-
# a typetree is available from the SerializedFile for this object
203-
export = obj.object_reader.read_typetree()
204-
elif isinstance(obj, MonoBehaviour):
205-
# try to get the typetree from the MonoBehavior script
206-
script_ptr = obj.m_Script
207-
if script_ptr:
208-
# looks like we have a script
209-
script = script_ptr.read()
210-
# check if there is a locally stored typetree for it
211-
nodes = MONOBEHAVIOUR_TYPETREES.get(script.m_AssemblyName, {}).get(script.m_ClassName, None)
212-
if nodes:
213-
export = obj.object_reader.read_typetree(nodes)
214-
else:
215-
export = obj.object_reader.read_typetree()
203+
try:
204+
export = obj.parse_as_dict()
205+
except Exception:
206+
pass
216207

217208
if not export:
218209
extension = ".bin"
219-
export = obj.object_reader.raw_data
210+
export = obj.raw_data
220211
else:
221212
extension = ".json"
222213
export = json.dumps(export, indent=4, ensure_ascii=False).encode("utf8", errors="surrogateescape")
223214
with open(f"{fp}{extension}", "wb") as f:
224215
f.write(export)
225-
return [(obj.assets_file, obj.object_reader.path_id)]
216+
return [(obj.assets_file, obj.path_id)]
226217

227218

228-
def exportAudioClip(obj: AudioClip, fp: str, extension: str = "") -> List[Tuple[SerializedFile, int]]:
229-
samples = obj.samples
219+
def exportAudioClip(obj: ObjectReader, fp: str, extension: str = "") -> List[Tuple[SerializedFile, int]]:
220+
clip = obj.parse_as_object()
221+
samples = clip.samples
230222
if len(samples) == 0:
231223
pass
232224
elif len(samples) == 1:
@@ -237,19 +229,18 @@ def exportAudioClip(obj: AudioClip, fp: str, extension: str = "") -> List[Tuple[
237229
for name, clip_data in samples.items():
238230
with open(os.path.join(fp, f"{name}.wav"), "wb") as f:
239231
f.write(clip_data)
240-
return [(obj.assets_file, obj.object_reader.path_id)]
232+
return [(obj.assets_file, obj.path_id)]
241233

242234

243-
def exportSprite(obj: Sprite, fp: str, extension: str = ".png") -> List[Tuple[SerializedFile, int]]:
244-
if not extension:
245-
extension = ".png"
246-
obj.image.save(f"{fp}{extension}")
235+
def exportSprite(obj: ObjectReader, fp: str, extension: str = ".png") -> List[Tuple[SerializedFile, int]]:
236+
sprite = obj.parse_as_object()
237+
sprite.image.save(f"{fp}{extension}")
247238
exported = [
248-
(obj.assets_file, obj.object_reader.path_id),
249-
(obj.m_RD.texture.assetsfile, obj.m_RD.texture.path_id),
239+
(obj.assets_file, obj.path_id),
240+
(sprite.m_RD.texture.assetsfile, sprite.m_RD.texture.path_id),
250241
]
251-
alpha_assets_file = getattr(obj.m_RD.alphaTexture, "assets_file", None)
252-
alpha_path_id = getattr(obj.m_RD.alphaTexture, "path_id", None)
242+
alpha_assets_file = getattr(sprite.m_RD.alphaTexture, "assets_file", None)
243+
alpha_path_id = getattr(sprite.m_RD.alphaTexture, "path_id", None)
253244
if alpha_path_id and alpha_assets_file:
254245
exported.append((alpha_assets_file, alpha_path_id))
255246
return exported
@@ -303,34 +294,34 @@ def exportGameObject(obj: GameObject, fp: str, extension: str = "") -> List[Tupl
303294
MONOBEHAVIOUR_TYPETREES: Dict[ASSEMBLY_NAME_DLL, Dict[CLASS_NAME, List[Dict]]] = {}
304295

305296

306-
def crawl_obj(obj: Object, ret: Optional[dict] = None) -> Dict[int, Union[Object, PPtr]]:
297+
def crawl_obj(obj: Union[Object, ObjectReader, PPtr], ret: Optional[dict] = None) -> Dict[int, Union[Object, PPtr]]:
307298
"""Crawls through the data struture of the object
308299
and returns a list of all the components.
309300
"""
310301
if not ret:
311302
ret = {}
312303

304+
values: Sequence
313305
if isinstance(obj, PPtr):
314-
if obj.path_id == 0 and obj.file_id == 0 and obj.index == -2:
306+
if obj.m_PathID == 0 and obj.m_FileID == 0 and obj.m_Index == -2:
315307
return ret
316308
try:
317-
obj = obj.read()
309+
instance = obj.deref_parse_as_dict()
310+
values = instance.values()
318311
except AttributeError:
319312
return ret
313+
elif isinstance(obj, Object):
314+
values = obj.__dict__.values()
315+
elif isinstance(obj, ObjectReader):
316+
values = obj.parse_as_dict().values()
320317
else:
321318
return ret
322-
ret[obj.path_id] = obj
323319

324-
# MonoBehaviour really on their typetree
325-
# while Object denotes that the class of the object isn't implemented yet
326-
if isinstance(obj, (MonoBehaviour, Object)):
327-
data = obj.read_typetree().__dict__.values()
328-
else:
329-
data = obj.__dict__.values()
320+
ret[obj.m_PathID] = obj
330321

331-
for value in flatten(data):
322+
for value in flatten(values):
332323
if isinstance(value, (Object, PPtr)):
333-
if value.path_id in ret:
324+
if value.m_PathID in ret:
334325
continue
335326
crawl_obj(value, ret)
336327

0 commit comments

Comments
 (0)