Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from K0lb3:master #2

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ec74e4b
cpp implementation for ArchiveStorageDecryptor.decrypt_block
AXiX-official Oct 25, 2024
f510d24
Returns a new bytes object instead of modifying it in place.
AXiX-official Oct 25, 2024
a3a5cd5
copy bytes by PyBytes_FromObject
AXiX-official Oct 26, 2024
65deb2a
some fix for Python api usage according to comment
AXiX-official Oct 27, 2024
12fc9d4
1.20.11 version bump
K0lb3 Oct 27, 2024
c2805e3
TypeTreeHelper.cpp - fix __node__ value assignment
K0lb3 Oct 28, 2024
68c8e36
TypeTreeHelper - format and add view.buf release check
K0lb3 Oct 28, 2024
a5de61e
Mesh.cpp - parse directly into buffer and be smarter about result cre…
K0lb3 Oct 28, 2024
898c5a7
UnityPyBoost - remove deprecated setup.py
K0lb3 Oct 28, 2024
e63618e
1.20.12 - version bump
K0lb3 Oct 28, 2024
6daa1f7
fix: export Shader (#280)
martinwang2002 Nov 5, 2024
09919e1
feat: arm64 for fmod and AudioClipConverter
martinwang2002 Nov 8, 2024
9475c47
AudioClipConverter - refactor sound format dependent export and add o…
K0lb3 Nov 8, 2024
5d6de1a
setup.py - include arm64 fmod
K0lb3 Nov 8, 2024
87e7d9f
fix tools.extractor and add a test for it
K0lb3 Nov 13, 2024
d2d4c16
1.20.13 version bump
K0lb3 Nov 13, 2024
72611c7
ObjectReader - add parse_as functions, PPtr - fix parse_as functions,…
K0lb3 Nov 16, 2024
8fa1464
1.20.14 - version bumb
K0lb3 Nov 16, 2024
d2c6697
Fix: some type hints (tools/extractor, legacy patch stubs) (#285)
Nattsu39 Nov 18, 2024
03098aa
1.20.15 version bump
K0lb3 Nov 18, 2024
13e102b
1.20.16 - Texture2DConverter - astc decompress - fix decompress impor…
K0lb3 Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions UnityPy/UnityPyBoost.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ class TypeTreeNode:
m_MetaFlag: Optional[int] = None
m_RefTypeHash: Optional[int] = None
_clean_name: str

def decrypt_block(
index_bytes: Union[bytes, bytearray],
substitute_bytes: Union[bytes, bytearray],
data: Union[bytes, bytearray],
index: int,
) -> bytes: ...
2 changes: 1 addition & 1 deletion UnityPy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.20.10"
__version__ = "1.20.16"

from .environment import Environment as Environment
from .helpers.ArchiveStorageManager import (
Expand Down
12 changes: 7 additions & 5 deletions UnityPy/classes/PPtr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ def path_id(self) -> int:
def type(self) -> ClassIDType:
return self.deref().type

# backwards compatibility - to be removed in UnityPy 2
def read(self):
# backwards compatibility
return self.deref_parse_as_object()

# backwards compatibility - to be removed in UnityPy 2
def read_typetree(self):
return self.deref_parse_as_dict()

def deref(self, assetsfile: Optional[SerializedFile] = None) -> ObjectReader[T]:
assetsfile = assetsfile or self.assetsfile
if assetsfile is None:
Expand Down Expand Up @@ -85,14 +89,12 @@ def deref(self, assetsfile: Optional[SerializedFile] = None) -> ObjectReader[T]:
return cast("ObjectReader[T]", assetsfile.objects[self.m_PathID])

def deref_parse_as_object(self, assetsfile: Optional[SerializedFile] = None) -> T:
return self.deref(assetsfile).read()
return self.deref(assetsfile).parse_as_object()

def deref_parse_as_dict(
self, assetsfile: Optional[SerializedFile] = None
) -> dict[str, Any]:
ret = self.deref(assetsfile).parse_as_dict()
assert isinstance(ret, dict)
return ret
return self.deref(assetsfile).parse_as_dict()

def __bool__(self):
return self.m_PathID != 0
Expand Down
31 changes: 31 additions & 0 deletions UnityPy/classes/legacy_patch/AudioClip.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from typing import Dict, List, Optional

from UnityPy.classes.generated import SampleClip, StreamedResource

class AudioClip(SampleClip):
m_Name: str
m_3D: Optional[bool] = None
m_Ambisonic: Optional[bool] = None
m_AudioData: Optional[List[int]] = None
m_BitsPerSample: Optional[int] = None
m_Channels: Optional[int] = None
m_CompressionFormat: Optional[int] = None
m_Format: Optional[int] = None
m_Frequency: Optional[int] = None
m_IsTrackerFormat: Optional[bool] = None
m_Legacy3D: Optional[bool] = None
m_Length: Optional[float] = None
m_LoadInBackground: Optional[bool] = None
m_LoadType: Optional[int] = None
m_PreloadAudioData: Optional[bool] = None
m_Resource: Optional[StreamedResource] = None
m_Stream: Optional[int] = None
m_SubsoundIndex: Optional[int] = None
m_Type: Optional[int] = None
m_UseHardware: Optional[bool] = None

@property
def extension(self) -> str: ...

@property
def samples(self) -> Dict[str, bytes]: ...
26 changes: 26 additions & 0 deletions UnityPy/classes/legacy_patch/GameObject.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import List, Tuple, Union

from UnityPy.classes import Component, PPtr
from UnityPy.classes.generated import ComponentPair, EditorExtension

class GameObject(EditorExtension):
m_Component: Union[List[ComponentPair], List[Tuple[int, PPtr[Component]]]]
m_IsActive: Union[bool, int]
m_Layer: int
m_Name: str
m_Tag: int

@property
def m_Components(self) -> List[PPtr[Component]]: ...
@property
def m_Animator(self) -> Union[PPtr[Component], None]: ...
@property
def m_Animation(self) -> Union[PPtr[Component], None]: ...
@property
def m_Transform(self) -> Union[PPtr[Component], None]: ...
@property
def m_SkinnedMeshRenderer(self) -> Union[PPtr[Component], None]: ...
@property
def m_MeshRenderer(self) -> Union[PPtr[Component], None]: ...
@property
def m_MeshFilter(self) -> Union[PPtr[Component], None]: ...
50 changes: 50 additions & 0 deletions UnityPy/classes/legacy_patch/Mesh.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from typing import List, Optional, Union

from UnityPy.classes.generated import (AABB, BlendShapeData, BoneInfluence,
BoneWeights4, CompressedMesh,
MeshBlendShape, MeshBlendShapeVertex,
MinMaxAABB, NamedObject, StreamingInfo,
SubMesh, VariableBoneCountWeights,
VertexData)
from UnityPy.classes.math import (ColorRGBA, Matrix4x4f, Vector2f, Vector3f,
Vector4f)

class Mesh(NamedObject):
m_BindPose: List[Matrix4x4f]
m_CompressedMesh: CompressedMesh
m_IndexBuffer: List[int]
m_LocalAABB: AABB
m_MeshCompression: int
m_MeshUsageFlags: int
m_Name: str
m_SubMeshes: List[SubMesh]
m_BakedConvexCollisionMesh: Optional[List[int]] = None
m_BakedTriangleCollisionMesh: Optional[List[int]] = None
m_BoneNameHashes: Optional[List[int]] = None
m_BonesAABB: Optional[List[MinMaxAABB]] = None
m_CollisionTriangles: Optional[List[int]] = None
m_CollisionVertexCount: Optional[int] = None
m_Colors: Optional[List[ColorRGBA]] = None
m_CookingOptions: Optional[int] = None
m_IndexFormat: Optional[int] = None
m_IsReadable: Optional[bool] = None
m_KeepIndices: Optional[bool] = None
m_KeepVertices: Optional[bool] = None
m_MeshMetrics_0_: Optional[float] = None
m_MeshMetrics_1_: Optional[float] = None
m_Normals: Optional[List[Vector3f]] = None
m_RootBoneNameHash: Optional[int] = None
m_ShapeVertices: Optional[List[MeshBlendShapeVertex]] = None
m_Shapes: Optional[Union[BlendShapeData, List[MeshBlendShape]]] = None
m_Skin: Optional[Union[List[BoneInfluence], List[BoneWeights4]]] = None
m_StreamCompression: Optional[int] = None
m_StreamData: Optional[StreamingInfo] = None
m_Tangents: Optional[List[Vector4f]] = None
m_UV: Optional[List[Vector2f]] = None
m_UV1: Optional[List[Vector2f]] = None
m_Use16BitIndices: Optional[int] = None
m_VariableBoneCountWeights: Optional[VariableBoneCountWeights] = None
m_VertexData: Optional[VertexData] = None
m_Vertices: Optional[List[Vector3f]] = None

def export(self, format: str = "obj") -> str: ...
8 changes: 8 additions & 0 deletions UnityPy/classes/legacy_patch/Renderer.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from UnityPy.classes import PPtr
from UnityPy.classes.generated import Component
from UnityPy.classes.legacy_patch import GameObject

class Renderer(Component):
m_GameObject: PPtr[GameObject]

def export(self, export_dir: str) -> None: ...
25 changes: 25 additions & 0 deletions UnityPy/classes/legacy_patch/Shader.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import List, Optional, Tuple, Union

from UnityPy.classes import PPtr
from UnityPy.classes.generated import (GUID, NamedObject, SerializedShader,
Texture)

class Shader(NamedObject):
m_Name: str
compressedBlob: Optional[List[int]] = None
compressedLengths: Optional[Union[List[int], List[List[int]]]] = None
decompressedLengths: Optional[Union[List[int], List[List[int]]]] = None
decompressedSize: Optional[int] = None
m_AssetGUID: Optional[GUID] = None
m_Dependencies: Optional[List[PPtr[Shader]]] = None
m_NonModifiableTextures: Optional[List[Tuple[str, PPtr[Texture]]]] = None
m_ParsedForm: Optional[SerializedShader] = None
m_PathName: Optional[str] = None
m_Script: Optional[str] = None
m_ShaderIsBaked: Optional[bool] = None
m_SubProgramBlob: Optional[List[int]] = None
offsets: Optional[Union[List[int], List[List[int]]]] = None
platforms: Optional[List[int]] = None
stageCounts: Optional[List[int]] = None

def export(self) -> str: ...
29 changes: 29 additions & 0 deletions UnityPy/classes/legacy_patch/Sprite.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import List, Optional, Tuple

from PIL.Image import Image

from UnityPy.classes import PPtr
from UnityPy.classes.generated import (GUID, MonoBehaviour, NamedObject, Rectf,
SpriteAtlas, SpriteBone,
SpriteRenderData)
from UnityPy.classes.math import Vector2f, Vector4f

class Sprite(NamedObject):
m_Extrude: int
m_Name: str
m_Offset: Vector2f
m_PixelsToUnits: float
m_RD: SpriteRenderData
m_Rect: Rectf
m_AtlasTags: Optional[List[str]] = None
m_Bones: Optional[List[SpriteBone]] = None
m_Border: Optional[Vector4f] = None
m_IsPolygon: Optional[bool] = None
m_PhysicsShape: Optional[List[List[Vector2f]]] = None
m_Pivot: Optional[Vector2f] = None
m_RenderDataKey: Optional[Tuple[GUID, int]] = None
m_ScriptableObjects: Optional[List[PPtr[MonoBehaviour]]] = None
m_SpriteAtlas: Optional[PPtr[SpriteAtlas]] = None

@property
def image(self) -> Image: ...
45 changes: 45 additions & 0 deletions UnityPy/classes/legacy_patch/Texture2D.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from typing import BinaryIO, List, Optional, Union

from PIL.Image import Image

from UnityPy.classes.generated import GLTextureSettings, StreamingInfo, Texture

class Texture2D(Texture):
image_data: bytes
m_CompleteImageSize: int
m_Height: int
m_ImageCount: int
m_IsReadable: bool
m_LightmapFormat: int
m_Name: str
m_TextureDimension: int
m_TextureFormat: int
m_TextureSettings: GLTextureSettings
m_Width: int
m_ColorSpace: Optional[int] = None
m_DownscaleFallback: Optional[bool] = None
m_ForcedFallbackFormat: Optional[int] = None
m_IgnoreMasterTextureLimit: Optional[bool] = None
m_IgnoreMipmapLimit: Optional[bool] = None
m_IsAlphaChannelOptional: Optional[bool] = None
m_IsPreProcessed: Optional[bool] = None
m_MipCount: Optional[int] = None
m_MipMap: Optional[bool] = None
m_MipmapLimitGroupName: Optional[str] = None
m_MipsStripped: Optional[int] = None
m_PlatformBlob: Optional[List[int]] = None
m_ReadAllowed: Optional[bool] = None
m_StreamData: Optional[StreamingInfo] = None
m_StreamingMipmaps: Optional[bool] = None
m_StreamingMipmapsPriority: Optional[int] = None

@property
def image(self) -> Image: ...
def set_image(
self,
img: Union[Image, str, BinaryIO],
target_format: Optional[int] = None,
mipmap_count: int = 1,
) -> None: ...
def get_image_data(self) -> bytes: ...

29 changes: 29 additions & 0 deletions UnityPy/classes/legacy_patch/Texture2DArray.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import List, Optional

from PIL.Image import Image

from UnityPy.classes.generated import GLTextureSettings, StreamingInfo, Texture

class Texture2DArray(Texture):
image_data: bytes
m_ColorSpace: int
m_DataSize: int
m_Depth: int
m_Format: int
m_Height: int
m_IsReadable: bool
m_MipCount: int
m_Name: str
m_TextureSettings: GLTextureSettings
m_Width: int
m_DownscaleFallback: Optional[bool] = None
m_ForcedFallbackFormat: Optional[int] = None
m_IgnoreMipmapLimit: Optional[bool] = None
m_IsAlphaChannelOptional: Optional[bool] = None
m_MipmapLimitGroupName: Optional[str] = None
m_MipsStripped: Optional[int] = None
m_StreamData: Optional[StreamingInfo] = None
m_UsageMode: Optional[int] = None

@property
def images(self) -> List[Image]: ...
Loading