objectType = object.type.name
if objectType not in exportTypes:
return
fileData = object.read()
if hasattr(fileData, "name") == False or fileData.name is None:
return
fileName = fileData.name
exportFilePath = os.path.join(outputPath, objectType, fileName)
if not os.path.exists(os.path.dirname(exportFilePath)):
os.makedirs(os.path.dirname(exportFilePath))
match objectType:
case 'Texture2D':
exportFilePath += ".png"
if fileData.m_Width:
fileData.image.save(exportFilePath) # error code
case _:
print(f"Unknown type: {objectType}")
return
Error
An error occurred while executing to fileData.image.save(exportFilePath)
Traceback (most recent call last):
......
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\classes\Texture2D.py", line 13, in image
return Texture2DConverter.get_image_from_texture2d(self)
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\export\Texture2DConverter.py", line 101, in get_image_from_texture2d
image_data = copy(bytes(texture_2d.image_data))
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\classes\Texture2D.py", line 51, in image_data
self._image_data = get_resource_data(
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\helpers\ResourceReader.py", line 38, in get_resource_data
assets_file.load_dependencies(possible_names)
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\files\SerializedFile.py", line 312, in load_dependencies
self.environment.load_file(file_id.path, True)
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\environment.py", line 113, in load_file
file = os.path.join(self.path, file)
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python310\lib\ntpath.py", line 104, in join
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Code
Error An error occurred while executing to
fileData.image.save(exportFilePath)
Version:
Bug The image data of Texture2D cannot be obtained normally. The same error will occur even if
fileData.image
is called directly.To Reproduce The file with the error: eff_ps_env_sakura_001_lp.zip