Skip to content

Commit bc1361f

Browse files
AutumnSun1996K0lb3qiushiyang
authored
Fix Attribute Error for some assets when loading mesh (K0lb3#65)
* fix: fix attribute error for some assets * test: add test for mesh * fix: handle possible attribute error for `path` * replace try/except with hasattr * try to fix assertion issues on github actions * try fix assertion issues remove '\r' from both side before comparing * ci: skip publish if secrets are not available Co-authored-by: Rudolf Kolbe <[email protected]> Co-authored-by: qiushiyang <[email protected]>
1 parent 01d26b0 commit bc1361f

5 files changed

Lines changed: 1846 additions & 11 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
build-requirements: ${{ env.DEPENDENCIES }}
6464

6565
- name: Publish wheels to PyPI
66-
if: success() && github.event_name == 'push'
66+
if: success() && github.event_name == 'push' && env.TWINE_PASSWORD != ''
6767
env:
6868
TWINE_USERNAME: __token__
6969
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

UnityPy/classes/Mesh.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,19 @@ def __init__(self, reader):
519519
pass
520520

521521
def ProcessData(self):
522-
if self.m_StreamData and self.m_StreamData.path:
523-
if self.m_VertexData.m_VertexCount > 0:
524-
self.m_VertexData.m_DataSize = get_resource_data(
525-
self.m_StreamData.path,
526-
self.assets_file,
527-
self.m_StreamData.offset,
528-
self.m_StreamData.size,
529-
)
522+
# `m_StreamData` attribute may not exists for some assets
523+
if hasattr(self, "m_StreamData"):
524+
path = self.m_StreamData.path
525+
else:
526+
path = None
527+
if path and self.m_VertexData.m_VertexCount > 0:
528+
self.m_VertexData.m_DataSize = get_resource_data(
529+
self.m_StreamData.path,
530+
self.assets_file,
531+
self.m_StreamData.offset,
532+
self.m_StreamData.size,
533+
)
534+
530535
# Fix channel after 2018.3
531536
version = self.version
532537
if version >= (3, 5): # 3.5 and up

tests/samples/xinzexi_2_n_tex

619 KB
Binary file not shown.

0 commit comments

Comments
 (0)