Skip to content

Commit

Permalink
fix: export Shader
Browse files Browse the repository at this point in the history
  • Loading branch information
martinwang2002 authored and K0lb3 committed Nov 5, 2024
1 parent 7baccf7 commit a58d5e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions UnityPy/export/ShaderConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions UnityPy/tools/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
}
Expand Down

0 comments on commit a58d5e9

Please sign in to comment.