Skip to content

Commit be616e2

Browse files
committed
1.4.4
ImportHelper fix decode_atc_rgba8 fix
1 parent 97716ef commit be616e2

8 files changed

Lines changed: 18 additions & 9 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: |
3838
python -m pip install --upgrade pip
3939
pip install --upgrade pip wheel setuptools twine
40-
pip install pytest lz4 brotli Pillow fsb5 tex2img
40+
pip install pytest lz4 brotli Pillow fsb5 texture2ddecoder
4141
4242
- name: Install module
4343
run: |

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ __pycache__/
44
*.py[cod]
55
*$py.class
66
test.py
7-
7+
AssetStudio/
88
# C extensions
99
*.so
1010

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
env: PATH=/c/Python38:/c/Python38/Scripts:$PATH
1717
install:
1818
- pip3 install --upgrade pip # all three OSes agree about 'pip3'
19-
- pip3 install pillow
2019
- pip3 install pytest
20+
- pip3 install lz4 brotli Pillow fsb5 texture2ddecoder
2121
# 'python' points to Python 2.7 on macOS but points to Python 3.8 on Linux and Windows
2222
# 'python3' is a 'command not found' error on Windows but 'py' works on Windows only
2323
script:

UnityPy/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__version__ = "1.4.4"
2+
13
from .environment import Environment
24

35

UnityPy/environment.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ def load_zip_file(self, value):
9494
z = ZipFile(buffer)
9595

9696
for path in z.namelist():
97-
self.load_file(path, z.open(path).read())
97+
data = z.open(path).read()
98+
if data:
99+
self.load_file(path, data)
98100

99101
@property
100102
def objects(self):

UnityPy/export/Texture2DConverter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def pillow(
8686

8787
def atc(image_data: bytes, width: int, height: int, alpha: bool) -> Image:
8888
if alpha:
89-
image_data = texture2ddecoder.decode_atc_rgba8(image_data, width, height, alpha)
89+
image_data = texture2ddecoder.decode_atc_rgba8(image_data, width, height)
9090
else:
9191
image_data = texture2ddecoder.decode_atc_rgb4(image_data, width, height)
9292

UnityPy/helpers/ImportHelper.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ def check_file_type(input_) -> (FileType, EndianBinaryReader):
7878
elif isinstance(input_, EndianBinaryReader):
7979
reader = input_
8080
else:
81-
reader = EndianBinaryReader(input_)
82-
81+
try:
82+
reader = EndianBinaryReader(input_)
83+
except:
84+
return None, None
85+
8386
if reader.Length < 20:
8487
return FileType.ResourceFile, reader
8588

@@ -116,7 +119,7 @@ def check_file_type(input_) -> (FileType, EndianBinaryReader):
116119
file_size = reader.read_u_int()
117120
version = reader.read_u_int()
118121
data_offset = reader.read_u_int()
119-
122+
120123
if (
121124
version < 0
122125
or version > 100
@@ -126,6 +129,7 @@ def check_file_type(input_) -> (FileType, EndianBinaryReader):
126129
for x in [metadata_size, version, data_offset]
127130
]
128131
)
132+
or file_size < metadata_size
129133
):
130134
return FileType.ResourceFile, reader
131135

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import setuptools
2+
from UnityPy import __version__ as version
23

34
with open("README.md", "r") as fh:
45
long_description = fh.read()
56

67
setuptools.setup(
78
name="UnityPy",
89
packages=setuptools.find_packages(),
9-
version="1.4.2",
10+
version=version,
1011
author="K0lb3",
1112
description="A pythonic port of AssetStudio by Perfare",
1213
long_description=long_description,

0 commit comments

Comments
 (0)