diff --git a/UnityPy/export/ShaderConverter.py b/UnityPy/export/ShaderConverter.py index 66f27983..9e112856 100644 --- a/UnityPy/export/ShaderConverter.py +++ b/UnityPy/export/ShaderConverter.py @@ -68,11 +68,11 @@ def ConvertSerializedShader(m_Shader: Shader) -> str: decompressedSize = m_Shader.decompressedLengths[i] compressedBytes = compressed_blob[ - int(m_Shader.offsets[i][0]) : int(m_Shader.offsets[i][0]) - + compressedSize[0] + int(m_Shader.offsets[i]) : int(m_Shader.offsets[i]) + + compressedSize ] decompressedBytes = CompressionHelper.decompress_lz4( - compressedBytes, decompressedSize[0] + compressedBytes, decompressedSize ) shaderPrograms.append( @@ -654,7 +654,7 @@ def Export(self) -> str: sb.append("}\n") - if hasattr(self, "m_LocalKeywords") and len(self.m_LocalKeywords) > 0: + if hasattr(self, "m_LocalKeywords") and getattr(self, "m_LocalKeywords") is not None and len(self.m_LocalKeywords) > 0 : sb.append("Local Keywords { ") for keyword in self.m_LocalKeywords: sb.append('"{0}" '.format(keyword)) diff --git a/UnityPy/tools/extractor.py b/UnityPy/tools/extractor.py index 762e6bac..7983857d 100644 --- a/UnityPy/tools/extractor.py +++ b/UnityPy/tools/extractor.py @@ -179,7 +179,7 @@ def exportMesh(obj: Mesh, fp: str, extension=".obj") -> List[int]: return [(obj.assets_file, obj.path_id)] -def exporShader(obj: Shader, fp: str, extension=".txt") -> List[int]: +def exportShader(obj: Shader, fp: str, extension=".txt") -> List[int]: if not extension: extension = ".txt" with open(f"{fp}{extension}", "wt", encoding="utf8", newline="") as f: @@ -295,7 +295,7 @@ def exportGameObject(obj: GameObject, fp: str, extension: str = "") -> List[int] ClassIDType.Font: exportFont, ClassIDType.Mesh: exportMesh, ClassIDType.MonoBehaviour: exportMonoBehaviour, - ClassIDType.Shader: exporShader, + ClassIDType.Shader: exportShader, ClassIDType.TextAsset: exportTextAsset, ClassIDType.Texture2D: exportTexture2D, }