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

Fix: some type hints (tools/extractor, legacy patch stubs) #285

Merged
merged 5 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
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 List, Optional

from UnityPy.classes.generated import SampleClip, StreamedResource

def _AudioClip_extension(self: AudioClip) -> str: ...
def _AudioClip_samples(self: AudioClip) -> dict: ...

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
extension = property(_AudioClip_extension)
samples = property(_AudioClip_samples)
...
35 changes: 35 additions & 0 deletions UnityPy/classes/legacy_patch/GameObject.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from typing import List, Tuple, Union

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

def _GameObject_Components(self) -> List[PPtr[Component]]: ...
def _GameObject_GetComponent(self, type: ClassIDType) -> Union[PPtr[Component], None]: ...

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
m_Components = property(_GameObject_Components)
m_Animator = property(
lambda self: _GameObject_GetComponent(self, ClassIDType.Animator)
)
m_Animation = property(
lambda self: _GameObject_GetComponent(self, ClassIDType.Animation)
)
m_Transform = property(
lambda self: _GameObject_GetComponent(self, ClassIDType.Transform)
)
m_MeshRenderer = property(
lambda self: _GameObject_GetComponent(self, ClassIDType.MeshRenderer)
)
m_SkinnedMeshRenderer = property(
lambda self: _GameObject_GetComponent(self, ClassIDType.SkinnedMeshRenderer)
)
m_MeshFilter = property(
lambda self: _GameObject_GetComponent(self, ClassIDType.MeshFilter)
)
...
52 changes: 52 additions & 0 deletions UnityPy/classes/legacy_patch/Mesh.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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)

def _Mesh_export(self: Mesh, format: str = "obj") -> str: ...

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
export = _Mesh_export
...
13 changes: 13 additions & 0 deletions UnityPy/classes/legacy_patch/Renderer.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from UnityPy.classes import PPtr
from UnityPy.classes.generated import Component
from UnityPy.classes.legacy_patch import GameObject


def export(self, export_dir: str) -> None: ...

_Renderer_export = export

class Renderer(Component):
m_GameObject: PPtr[GameObject]
export = _Renderer_export
...
28 changes: 28 additions & 0 deletions UnityPy/classes/legacy_patch/Shader.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from typing import List, Optional, Tuple, Union

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

def _Shader_export(self: Shader) -> str: ...

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
export = _Shader_export
...

30 changes: 30 additions & 0 deletions UnityPy/classes/legacy_patch/Sprite.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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

def _Sprite_image(self: Sprite) -> Image: ...

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
image = property(_Sprite_image)
...
47 changes: 47 additions & 0 deletions UnityPy/classes/legacy_patch/Texture2D.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from typing import BinaryIO, List, Optional, Union

from PIL.Image import Image

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

def _Texture2d_get_image(self: Texture2D) -> Image: ...
def _Texture2d_set_image(
self: Texture2D,
img: Union[Image, str, BinaryIO],
target_format: Optional[int] = None,
mipmap_count: int = 1,
) -> None: ...
def _Texture2D_get_image_data(self: Texture2D) -> bytes: ...

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
image = property(_Texture2d_get_image, _Texture2d_set_image)
set_image = _Texture2d_set_image
get_image_data = _Texture2D_get_image_data
...
30 changes: 30 additions & 0 deletions UnityPy/classes/legacy_patch/Texture2DArray.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from typing import List, Optional

from PIL.Image import Image

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

def _Texture2DArray_get_images(self: Texture2DArray) -> List[Image]: ...

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
images = property(_Texture2DArray_get_images)
...
Loading