-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: some type hints (tools/extractor, legacy patch stubs) (#285)
* fix tools.extractor type hints * classes.generated - add legacy patch type hints * Creating type stubs for legacy patches This is better than putting all patched classes into __init__.pyi, and may be worth it given the backwards-compatible immutability of the legacy patch. * better legacy patch stub style * Remove meaningless stub definitions for legacy patches.
- Loading branch information
Showing
9 changed files
with
260 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters