A Unity asset extractor for Python based on AssetStudio that supports extraction, editing, and manipulation of Unity game assets.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Complete set of Unity enumerations and constants including texture formats, audio types, build targets, and other Unity-specific identifiers used throughout the asset system.
Fundamental Unity identifiers and type classifications.
class ClassIDType(Enum):
"""
Unity object class identifiers.
Common values:
- GameObject: 1
- Texture2D: 28
- AudioClip: 83
- Mesh: 43
- Sprite: 213
- Shader: 48
"""
class BuildTarget(Enum):
"""
Unity build target platforms.
Common values:
- StandaloneWindows: 5
- StandaloneOSX: 2
- iOS: 9
- Android: 13
- WebGL: 20
- StandaloneLinux64: 24
"""
class FileType(Enum):
"""
Unity file type identifiers.
Values:
- AssetsFile: Unity serialized assets
- BundleFile: Asset bundle
- WebFile: Web streaming file
- ResourceFile: Unity resource file
"""Format specifications for textures, graphics, and rendering.
class TextureFormat(Enum):
"""
Unity texture pixel formats.
Common formats:
- ARGB32: 5 - 32-bit ARGB
- RGB24: 3 - 24-bit RGB
- RGBA32: 4 - 32-bit RGBA
- DXT1: 10 - DXT1 compression
- DXT5: 12 - DXT5 compression
- ETC_RGB4: 34 - ETC1 4-bit RGB
- ASTC_4x4: 48 - ASTC 4x4 compression
- BC7: 25 - BC7 compression
"""
class GraphicsFormat(Enum):
"""
Modern graphics API formats.
Common formats:
- R8G8B8A8_UNorm: 8-bit RGBA unsigned normalized
- R8G8B8_UNorm: 8-bit RGB unsigned normalized
- BC1_RGB_UNorm: BC1 RGB compression
- BC3_RGBA_UNorm: BC3 RGBA compression
- ASTC_4x4_UNorm: ASTC 4x4 unsigned normalized
"""
class TextureDimension(Enum):
"""
Texture dimension types.
Values:
- Unknown: -1
- None: 0
- Tex2D: 2 - 2D texture
- Tex3D: 3 - 3D volume texture
- Cube: 4 - Cube map
- Tex2DArray: 5 - 2D texture array
- CubeArray: 6 - Cube map array
"""Audio format and compression specifications.
class AudioType(Enum):
"""
Audio file format types.
Values:
- UNKNOWN: 0
- ACC: 1 - AAC format
- AIFF: 2 - AIFF format
- IT: 10 - Impulse Tracker module
- MOD: 12 - ProTracker module
- MPEG: 13 - MPEG audio
- OGGVORBIS: 14 - OGG Vorbis
- S3M: 17 - ScreamTracker 3 module
- WAV: 20 - WAV format
- XM: 21 - Extended module
- XMA: 22 - Xbox Media Audio
- VAG: 23 - PlayStation VAG
- AUDIOQUEUE: 24 - iOS AudioQueue
"""
class AudioCompressionFormat(Enum):
"""
Audio compression formats.
Values:
- PCM: 0 - Uncompressed PCM
- Vorbis: 1 - OGG Vorbis compression
- ADPCM: 2 - ADPCM compression
- MP3: 3 - MP3 compression
- PSMADPCM: 4 - PlayStation ADPCM
- HEVAG: 5 - PlayStation Vita HEVAG
- XMA: 6 - Xbox Media Audio
- AAC: 7 - AAC compression
- GCADPCM: 8 - GameCube ADPCM
- ATRAC9: 9 - PlayStation ATRAC9
"""
AUDIO_TYPE_EXTEMSION: Dict[AudioType, str]
"""
Mapping of audio types to file extensions.
Examples:
- AudioType.WAV: ".wav"
- AudioType.OGGVORBIS: ".ogg"
- AudioType.MPEG: ".mp3"
- AudioType.AIFF: ".aiff"
"""Specifications for sprite processing and 2D graphics.
class SpriteMeshType(Enum):
"""
Sprite mesh generation types.
Values:
- FullRect: 0 - Full rectangle mesh
- Tight: 1 - Tight mesh following sprite outline
"""
class SpritePackingMode(Enum):
"""
Sprite atlas packing modes.
Values:
- None: 0 - No packing
- Tight: 1 - Tight packing
- Rectangle: 4 - Rectangle packing
"""
class SpritePackingRotation(Enum):
"""
Sprite rotation in atlas packing.
Values:
- None: 0 - No rotation
- FlipHorizontal: 1 - Horizontal flip
- FlipVertical: 2 - Vertical flip
- Rotate180: 3 - 180 degree rotation
- Rotate90: 4 - 90 degree rotation
"""3D rendering and mesh processing specifications.
class GfxPrimitiveType(Enum):
"""
Graphics primitive types for rendering.
Values:
- Triangles: 0 - Triangle list
- TriangleStrip: 1 - Triangle strip
- Quads: 2 - Quad list
- Lines: 3 - Line list
- LineStrip: 4 - Line strip
- Points: 5 - Point list
"""
class MeshTopology(Enum):
"""
Mesh topology types.
Values:
- Triangles: 0 - Triangle mesh
- Quads: 2 - Quad mesh
- Lines: 3 - Line mesh
- LineStrip: 4 - Line strip mesh
- Points: 5 - Point cloud mesh
"""
class VertexFormat(Enum):
"""
Vertex attribute data formats.
Values:
- Float: 0 - 32-bit float
- Float16: 1 - 16-bit half float
- UNorm8: 2 - 8-bit unsigned normalized
- SNorm8: 3 - 8-bit signed normalized
- UNorm16: 4 - 16-bit unsigned normalized
- SNorm16: 5 - 16-bit signed normalized
- UInt8: 6 - 8-bit unsigned integer
- SInt8: 7 - 8-bit signed integer
- UInt16: 8 - 16-bit unsigned integer
- SInt16: 9 - 16-bit signed integer
- UInt32: 10 - 32-bit unsigned integer
- SInt32: 11 - 32-bit signed integer
"""Shader compilation and GPU program specifications.
class ShaderCompilerPlatform(Enum):
"""
Shader compiler target platforms.
Values:
- None: 0
- GL: 1 - OpenGL
- D3D9: 2 - Direct3D 9
- D3D11: 4 - Direct3D 11
- GLES20: 5 - OpenGL ES 2.0
- GLES3x: 14 - OpenGL ES 3.x
- Metal: 11 - Apple Metal
- Vulkan: 18 - Vulkan API
- D3D12: 16 - Direct3D 12
"""
class ShaderGpuProgramType(Enum):
"""
GPU shader program types.
Values:
- Unknown: 0
- GLLegacy: 1 - Legacy OpenGL
- GLES31AEP: 2 - OpenGL ES 3.1 AEP
- GLES31: 3 - OpenGL ES 3.1
- GLES3: 4 - OpenGL ES 3.0
- GLES: 5 - OpenGL ES 2.0
- GLCore32: 6 - OpenGL Core 3.2
- GLCore41: 7 - OpenGL Core 4.1
- GLCore43: 8 - OpenGL Core 4.3
- DX9VertexSM20: 9 - DirectX 9 Vertex Shader 2.0
- DX9VertexSM30: 10 - DirectX 9 Vertex Shader 3.0
- DX9PixelSM20: 11 - DirectX 9 Pixel Shader 2.0
- DX9PixelSM30: 12 - DirectX 9 Pixel Shader 3.0
- DX10Level9Vertex: 13 - DirectX 10 Level 9 Vertex
- DX10Level9Pixel: 14 - DirectX 10 Level 9 Pixel
- DX11VertexSM40: 15 - DirectX 11 Vertex Shader 4.0
- DX11VertexSM50: 16 - DirectX 11 Vertex Shader 5.0
- DX11PixelSM40: 17 - DirectX 11 Pixel Shader 4.0
- DX11PixelSM50: 18 - DirectX 11 Pixel Shader 5.0
- DX11GeometrySM40: 19 - DirectX 11 Geometry Shader 4.0
- DX11GeometrySM50: 20 - DirectX 11 Geometry Shader 5.0
- DX11HullSM50: 21 - DirectX 11 Hull Shader 5.0
- DX11DomainSM50: 22 - DirectX 11 Domain Shader 5.0
- MetalVS: 23 - Metal Vertex Shader
- MetalFS: 24 - Metal Fragment Shader
- SPIRV: 25 - SPIR-V bytecode
- ConsoleVS: 26 - Console Vertex Shader
- ConsoleFS: 27 - Console Fragment Shader
- ConsoleHS: 28 - Console Hull Shader
- ConsoleDS: 29 - Console Domain Shader
- ConsoleGS: 30 - Console Geometry Shader
"""
class PassType(Enum):
"""
Shader pass types.
Values:
- Normal: 0 - Standard rendering pass
- Use: 1 - Use pass (reference another shader)
- Grab: 2 - Grab pass (render to texture)
"""Asset bundle and archive format specifications.
class ArchiveFlags(Enum):
"""
Asset bundle archive flags.
Values:
- CompressionTypeMask: 0x3F - Compression type mask
- BlocksAndDirectoryInfoCombined: 0x40 - Combined info flag
- BlocksInfoAtTheEnd: 0x80 - Info at end flag
- OldWebPluginCompatibility: 0x100 - Legacy compatibility
"""
class ArchiveFlagsOld(Enum):
"""
Legacy asset bundle archive flags.
Values:
- CompressionTypeMask: 0x3F - Compression type mask
"""
class CompressionFlags(Enum):
"""
Asset bundle compression types.
Values:
- None: 0 - No compression
- LZMA: 1 - LZMA compression
- LZ4: 2 - LZ4 compression
- LZ4HC: 3 - LZ4 high compression
"""Miscellaneous Unity identifiers and property types.
class CommonString(Enum):
"""
Common Unity string identifiers.
Values include frequently used Unity strings for optimization.
"""
class SerializedPropertyType(Enum):
"""
Unity serialized property data types.
Values:
- Generic: 0 - Generic serializable object
- Integer: 1 - Integer value
- Boolean: 2 - Boolean value
- Float: 3 - Float value
- String: 4 - String value
- Color: 5 - Color value
- ObjectReference: 6 - Unity object reference
- LayerMask: 7 - Layer mask
- Enum: 8 - Enumeration value
- Vector2: 9 - 2D vector
- Vector3: 10 - 3D vector
- Vector4: 11 - 4D vector
- Rect: 12 - Rectangle
- ArraySize: 13 - Array size
- Character: 14 - Character
- AnimationCurve: 15 - Animation curve
- Bounds: 16 - 3D bounds
- Gradient: 17 - Color gradient
- Quaternion: 18 - Quaternion rotation
"""import UnityPy
from UnityPy.enums import TextureFormat, GraphicsFormat
env = UnityPy.load("texture_assets/")
for obj in env.objects:
if obj.type.name == "Texture2D":
texture = obj.read()
# Check texture format
format_enum = texture.m_TextureFormat
print(f"Texture: {texture.name}")
print(f"Format: {format_enum} ({format_enum.name})")
# Handle different formats
if format_enum == TextureFormat.DXT1:
print("DXT1 compressed texture")
elif format_enum in [TextureFormat.ARGB32, TextureFormat.RGBA32]:
print("Uncompressed RGBA texture")
elif format_enum.name.startswith("ASTC"):
print("ASTC compressed texture")
# Check if format is supported for export
supported_formats = [
TextureFormat.ARGB32,
TextureFormat.RGBA32,
TextureFormat.RGB24,
TextureFormat.DXT1,
TextureFormat.DXT5
]
if format_enum in supported_formats:
texture.save(f"exports/{texture.name}.png")
else:
print(f"Format {format_enum.name} may need special handling")import UnityPy
from UnityPy.enums import AudioType, AudioCompressionFormat, AUDIO_TYPE_EXTEMSION
env = UnityPy.load("audio_assets/")
for obj in env.objects:
if obj.type.name == "AudioClip":
audio = obj.read()
# Get audio format information
compression_format = audio.m_CompressionFormat
print(f"Audio: {audio.name}")
print(f"Compression: {compression_format.name}")
print(f"Length: {audio.m_Length:.2f}s")
print(f"Sample Rate: {audio.m_Frequency}Hz")
print(f"Channels: {audio.m_Channels}")
# Determine output format based on compression
if compression_format == AudioCompressionFormat.PCM:
output_ext = ".wav"
elif compression_format == AudioCompressionFormat.Vorbis:
output_ext = ".ogg"
elif compression_format == AudioCompressionFormat.MP3:
output_ext = ".mp3"
else:
output_ext = ".wav" # Default to WAV
try:
audio.save(f"exports/{audio.name}{output_ext}")
except Exception as e:
print(f"Failed to export: {e}")import UnityPy
from UnityPy.enums import BuildTarget
env = UnityPy.load("platform_specific_assets/")
# Check build target from serialized files
for filename, file_obj in env.files.items():
if hasattr(file_obj, 'target_platform'):
target = file_obj.target_platform
print(f"File: {filename}")
print(f"Target Platform: {target.name} ({target.value})")
# Handle platform-specific logic
if target == BuildTarget.Android:
print("Android-specific assets")
elif target == BuildTarget.iOS:
print("iOS-specific assets")
elif target in [BuildTarget.StandaloneWindows, BuildTarget.StandaloneWindows64]:
print("Windows-specific assets")import UnityPy
from UnityPy.enums import ShaderCompilerPlatform, ShaderGpuProgramType
env = UnityPy.load("shader_assets/")
for obj in env.objects:
if obj.type.name == "Shader":
shader = obj.read()
print(f"Shader: {shader.name}")
# Access parsed shader form if available
if hasattr(shader, 'm_ParsedForm') and shader.m_ParsedForm:
parsed = shader.m_ParsedForm
# Check supported platforms
if hasattr(parsed, 'm_Platforms'):
platforms = parsed.m_Platforms
print("Supported platforms:")
for platform in platforms:
if isinstance(platform, ShaderCompilerPlatform):
print(f" - {platform.name}")
# Check GPU program requirements
if hasattr(parsed, 'm_SubShaders'):
for subshader in parsed.m_SubShaders:
if hasattr(subshader, 'm_Passes'):
for pass_data in subshader.m_Passes:
if hasattr(pass_data, 'm_ProgVertex'):
vertex_prog = pass_data.m_ProgVertex
if hasattr(vertex_prog, 'm_SubPrograms'):
for subprog in vertex_prog.m_SubPrograms:
if hasattr(subprog, 'm_GpuProgramType'):
gpu_type = subprog.m_GpuProgramType
print(f" GPU Program: {gpu_type.name}")import UnityPy
from UnityPy.enums import VertexFormat, MeshTopology
env = UnityPy.load("mesh_assets/")
for obj in env.objects:
if obj.type.name == "Mesh":
mesh = obj.read()
print(f"Mesh: {mesh.name}")
print(f"Vertices: {len(mesh.vertices) if mesh.vertices else 0}")
# Check mesh topology
if hasattr(mesh, 'm_Topology'):
topology = mesh.m_Topology
if topology == MeshTopology.Triangles:
print("Triangle mesh")
elif topology == MeshTopology.Quads:
print("Quad mesh")
elif topology == MeshTopology.Lines:
print("Line mesh")
# Analyze vertex channels if available
if hasattr(mesh, 'm_VertexData') and mesh.m_VertexData:
vertex_data = mesh.m_VertexData
if hasattr(vertex_data, 'm_Channels'):
print("Vertex channels:")
for i, channel in enumerate(vertex_data.m_Channels):
if hasattr(channel, 'format') and channel.format != VertexFormat.Float:
print(f" Channel {i}: {channel.format.name}")
elif hasattr(channel, 'm_Format'):
format_val = channel.m_Format
if isinstance(format_val, VertexFormat):
print(f" Channel {i}: {format_val.name}")import UnityPy
from UnityPy.enums import CompressionFlags
env = UnityPy.load("bundle_assets/")
for filename, file_obj in env.files.items():
if hasattr(file_obj, 'signature') and file_obj.signature == "UnityFS":
# This is a bundle file
print(f"Bundle: {filename}")
if hasattr(file_obj, 'm_Header'):
header = file_obj.m_Header
if hasattr(header, 'flags'):
flags = header.flags
# Extract compression type from flags
compression_type = flags & 0x3F # CompressionTypeMask
if compression_type == CompressionFlags.None.value:
print(" Compression: None")
elif compression_type == CompressionFlags.LZMA.value:
print(" Compression: LZMA")
elif compression_type == CompressionFlags.LZ4.value:
print(" Compression: LZ4")
elif compression_type == CompressionFlags.LZ4HC.value:
print(" Compression: LZ4HC")
else:
print(f" Compression: Unknown ({compression_type})")Install with Tessl CLI
npx tessl i tessl/pypi-unitypy