0
# Enumerations and Constants
1
2
Complete set of Unity enumerations and constants including texture formats, audio types, build targets, and other Unity-specific identifiers used throughout the asset system.
3
4
## Capabilities
5
6
### Core Unity Enumerations
7
8
Fundamental Unity identifiers and type classifications.
9
10
```python { .api }
11
class ClassIDType(Enum):
12
"""
13
Unity object class identifiers.
14
15
Common values:
16
- GameObject: 1
17
- Texture2D: 28
18
- AudioClip: 83
19
- Mesh: 43
20
- Sprite: 213
21
- Shader: 48
22
"""
23
24
class BuildTarget(Enum):
25
"""
26
Unity build target platforms.
27
28
Common values:
29
- StandaloneWindows: 5
30
- StandaloneOSX: 2
31
- iOS: 9
32
- Android: 13
33
- WebGL: 20
34
- StandaloneLinux64: 24
35
"""
36
37
class FileType(Enum):
38
"""
39
Unity file type identifiers.
40
41
Values:
42
- AssetsFile: Unity serialized assets
43
- BundleFile: Asset bundle
44
- WebFile: Web streaming file
45
- ResourceFile: Unity resource file
46
"""
47
```
48
49
### Texture and Graphics Enumerations
50
51
Format specifications for textures, graphics, and rendering.
52
53
```python { .api }
54
class TextureFormat(Enum):
55
"""
56
Unity texture pixel formats.
57
58
Common formats:
59
- ARGB32: 5 - 32-bit ARGB
60
- RGB24: 3 - 24-bit RGB
61
- RGBA32: 4 - 32-bit RGBA
62
- DXT1: 10 - DXT1 compression
63
- DXT5: 12 - DXT5 compression
64
- ETC_RGB4: 34 - ETC1 4-bit RGB
65
- ASTC_4x4: 48 - ASTC 4x4 compression
66
- BC7: 25 - BC7 compression
67
"""
68
69
class GraphicsFormat(Enum):
70
"""
71
Modern graphics API formats.
72
73
Common formats:
74
- R8G8B8A8_UNorm: 8-bit RGBA unsigned normalized
75
- R8G8B8_UNorm: 8-bit RGB unsigned normalized
76
- BC1_RGB_UNorm: BC1 RGB compression
77
- BC3_RGBA_UNorm: BC3 RGBA compression
78
- ASTC_4x4_UNorm: ASTC 4x4 unsigned normalized
79
"""
80
81
class TextureDimension(Enum):
82
"""
83
Texture dimension types.
84
85
Values:
86
- Unknown: -1
87
- None: 0
88
- Tex2D: 2 - 2D texture
89
- Tex3D: 3 - 3D volume texture
90
- Cube: 4 - Cube map
91
- Tex2DArray: 5 - 2D texture array
92
- CubeArray: 6 - Cube map array
93
"""
94
```
95
96
### Audio Enumerations
97
98
Audio format and compression specifications.
99
100
```python { .api }
101
class AudioType(Enum):
102
"""
103
Audio file format types.
104
105
Values:
106
- UNKNOWN: 0
107
- ACC: 1 - AAC format
108
- AIFF: 2 - AIFF format
109
- IT: 10 - Impulse Tracker module
110
- MOD: 12 - ProTracker module
111
- MPEG: 13 - MPEG audio
112
- OGGVORBIS: 14 - OGG Vorbis
113
- S3M: 17 - ScreamTracker 3 module
114
- WAV: 20 - WAV format
115
- XM: 21 - Extended module
116
- XMA: 22 - Xbox Media Audio
117
- VAG: 23 - PlayStation VAG
118
- AUDIOQUEUE: 24 - iOS AudioQueue
119
"""
120
121
class AudioCompressionFormat(Enum):
122
"""
123
Audio compression formats.
124
125
Values:
126
- PCM: 0 - Uncompressed PCM
127
- Vorbis: 1 - OGG Vorbis compression
128
- ADPCM: 2 - ADPCM compression
129
- MP3: 3 - MP3 compression
130
- PSMADPCM: 4 - PlayStation ADPCM
131
- HEVAG: 5 - PlayStation Vita HEVAG
132
- XMA: 6 - Xbox Media Audio
133
- AAC: 7 - AAC compression
134
- GCADPCM: 8 - GameCube ADPCM
135
- ATRAC9: 9 - PlayStation ATRAC9
136
"""
137
138
AUDIO_TYPE_EXTEMSION: Dict[AudioType, str]
139
"""
140
Mapping of audio types to file extensions.
141
142
Examples:
143
- AudioType.WAV: ".wav"
144
- AudioType.OGGVORBIS: ".ogg"
145
- AudioType.MPEG: ".mp3"
146
- AudioType.AIFF: ".aiff"
147
"""
148
```
149
150
### Sprite and 2D Graphics Enumerations
151
152
Specifications for sprite processing and 2D graphics.
153
154
```python { .api }
155
class SpriteMeshType(Enum):
156
"""
157
Sprite mesh generation types.
158
159
Values:
160
- FullRect: 0 - Full rectangle mesh
161
- Tight: 1 - Tight mesh following sprite outline
162
"""
163
164
class SpritePackingMode(Enum):
165
"""
166
Sprite atlas packing modes.
167
168
Values:
169
- None: 0 - No packing
170
- Tight: 1 - Tight packing
171
- Rectangle: 4 - Rectangle packing
172
"""
173
174
class SpritePackingRotation(Enum):
175
"""
176
Sprite rotation in atlas packing.
177
178
Values:
179
- None: 0 - No rotation
180
- FlipHorizontal: 1 - Horizontal flip
181
- FlipVertical: 2 - Vertical flip
182
- Rotate180: 3 - 180 degree rotation
183
- Rotate90: 4 - 90 degree rotation
184
"""
185
```
186
187
### Rendering and Mesh Enumerations
188
189
3D rendering and mesh processing specifications.
190
191
```python { .api }
192
class GfxPrimitiveType(Enum):
193
"""
194
Graphics primitive types for rendering.
195
196
Values:
197
- Triangles: 0 - Triangle list
198
- TriangleStrip: 1 - Triangle strip
199
- Quads: 2 - Quad list
200
- Lines: 3 - Line list
201
- LineStrip: 4 - Line strip
202
- Points: 5 - Point list
203
"""
204
205
class MeshTopology(Enum):
206
"""
207
Mesh topology types.
208
209
Values:
210
- Triangles: 0 - Triangle mesh
211
- Quads: 2 - Quad mesh
212
- Lines: 3 - Line mesh
213
- LineStrip: 4 - Line strip mesh
214
- Points: 5 - Point cloud mesh
215
"""
216
217
class VertexFormat(Enum):
218
"""
219
Vertex attribute data formats.
220
221
Values:
222
- Float: 0 - 32-bit float
223
- Float16: 1 - 16-bit half float
224
- UNorm8: 2 - 8-bit unsigned normalized
225
- SNorm8: 3 - 8-bit signed normalized
226
- UNorm16: 4 - 16-bit unsigned normalized
227
- SNorm16: 5 - 16-bit signed normalized
228
- UInt8: 6 - 8-bit unsigned integer
229
- SInt8: 7 - 8-bit signed integer
230
- UInt16: 8 - 16-bit unsigned integer
231
- SInt16: 9 - 16-bit signed integer
232
- UInt32: 10 - 32-bit unsigned integer
233
- SInt32: 11 - 32-bit signed integer
234
"""
235
```
236
237
### Shader and GPU Enumerations
238
239
Shader compilation and GPU program specifications.
240
241
```python { .api }
242
class ShaderCompilerPlatform(Enum):
243
"""
244
Shader compiler target platforms.
245
246
Values:
247
- None: 0
248
- GL: 1 - OpenGL
249
- D3D9: 2 - Direct3D 9
250
- D3D11: 4 - Direct3D 11
251
- GLES20: 5 - OpenGL ES 2.0
252
- GLES3x: 14 - OpenGL ES 3.x
253
- Metal: 11 - Apple Metal
254
- Vulkan: 18 - Vulkan API
255
- D3D12: 16 - Direct3D 12
256
"""
257
258
class ShaderGpuProgramType(Enum):
259
"""
260
GPU shader program types.
261
262
Values:
263
- Unknown: 0
264
- GLLegacy: 1 - Legacy OpenGL
265
- GLES31AEP: 2 - OpenGL ES 3.1 AEP
266
- GLES31: 3 - OpenGL ES 3.1
267
- GLES3: 4 - OpenGL ES 3.0
268
- GLES: 5 - OpenGL ES 2.0
269
- GLCore32: 6 - OpenGL Core 3.2
270
- GLCore41: 7 - OpenGL Core 4.1
271
- GLCore43: 8 - OpenGL Core 4.3
272
- DX9VertexSM20: 9 - DirectX 9 Vertex Shader 2.0
273
- DX9VertexSM30: 10 - DirectX 9 Vertex Shader 3.0
274
- DX9PixelSM20: 11 - DirectX 9 Pixel Shader 2.0
275
- DX9PixelSM30: 12 - DirectX 9 Pixel Shader 3.0
276
- DX10Level9Vertex: 13 - DirectX 10 Level 9 Vertex
277
- DX10Level9Pixel: 14 - DirectX 10 Level 9 Pixel
278
- DX11VertexSM40: 15 - DirectX 11 Vertex Shader 4.0
279
- DX11VertexSM50: 16 - DirectX 11 Vertex Shader 5.0
280
- DX11PixelSM40: 17 - DirectX 11 Pixel Shader 4.0
281
- DX11PixelSM50: 18 - DirectX 11 Pixel Shader 5.0
282
- DX11GeometrySM40: 19 - DirectX 11 Geometry Shader 4.0
283
- DX11GeometrySM50: 20 - DirectX 11 Geometry Shader 5.0
284
- DX11HullSM50: 21 - DirectX 11 Hull Shader 5.0
285
- DX11DomainSM50: 22 - DirectX 11 Domain Shader 5.0
286
- MetalVS: 23 - Metal Vertex Shader
287
- MetalFS: 24 - Metal Fragment Shader
288
- SPIRV: 25 - SPIR-V bytecode
289
- ConsoleVS: 26 - Console Vertex Shader
290
- ConsoleFS: 27 - Console Fragment Shader
291
- ConsoleHS: 28 - Console Hull Shader
292
- ConsoleDS: 29 - Console Domain Shader
293
- ConsoleGS: 30 - Console Geometry Shader
294
"""
295
296
class PassType(Enum):
297
"""
298
Shader pass types.
299
300
Values:
301
- Normal: 0 - Standard rendering pass
302
- Use: 1 - Use pass (reference another shader)
303
- Grab: 2 - Grab pass (render to texture)
304
"""
305
```
306
307
### Bundle and Archive Enumerations
308
309
Asset bundle and archive format specifications.
310
311
```python { .api }
312
class ArchiveFlags(Enum):
313
"""
314
Asset bundle archive flags.
315
316
Values:
317
- CompressionTypeMask: 0x3F - Compression type mask
318
- BlocksAndDirectoryInfoCombined: 0x40 - Combined info flag
319
- BlocksInfoAtTheEnd: 0x80 - Info at end flag
320
- OldWebPluginCompatibility: 0x100 - Legacy compatibility
321
"""
322
323
class ArchiveFlagsOld(Enum):
324
"""
325
Legacy asset bundle archive flags.
326
327
Values:
328
- CompressionTypeMask: 0x3F - Compression type mask
329
"""
330
331
class CompressionFlags(Enum):
332
"""
333
Asset bundle compression types.
334
335
Values:
336
- None: 0 - No compression
337
- LZMA: 1 - LZMA compression
338
- LZ4: 2 - LZ4 compression
339
- LZ4HC: 3 - LZ4 high compression
340
"""
341
```
342
343
### Utility Enumerations
344
345
Miscellaneous Unity identifiers and property types.
346
347
```python { .api }
348
class CommonString(Enum):
349
"""
350
Common Unity string identifiers.
351
352
Values include frequently used Unity strings for optimization.
353
"""
354
355
class SerializedPropertyType(Enum):
356
"""
357
Unity serialized property data types.
358
359
Values:
360
- Generic: 0 - Generic serializable object
361
- Integer: 1 - Integer value
362
- Boolean: 2 - Boolean value
363
- Float: 3 - Float value
364
- String: 4 - String value
365
- Color: 5 - Color value
366
- ObjectReference: 6 - Unity object reference
367
- LayerMask: 7 - Layer mask
368
- Enum: 8 - Enumeration value
369
- Vector2: 9 - 2D vector
370
- Vector3: 10 - 3D vector
371
- Vector4: 11 - 4D vector
372
- Rect: 12 - Rectangle
373
- ArraySize: 13 - Array size
374
- Character: 14 - Character
375
- AnimationCurve: 15 - Animation curve
376
- Bounds: 16 - 3D bounds
377
- Gradient: 17 - Color gradient
378
- Quaternion: 18 - Quaternion rotation
379
"""
380
```
381
382
## Usage Examples
383
384
### Working with Texture Formats
385
386
```python
387
import UnityPy
388
from UnityPy.enums import TextureFormat, GraphicsFormat
389
390
env = UnityPy.load("texture_assets/")
391
392
for obj in env.objects:
393
if obj.type.name == "Texture2D":
394
texture = obj.read()
395
396
# Check texture format
397
format_enum = texture.m_TextureFormat
398
print(f"Texture: {texture.name}")
399
print(f"Format: {format_enum} ({format_enum.name})")
400
401
# Handle different formats
402
if format_enum == TextureFormat.DXT1:
403
print("DXT1 compressed texture")
404
elif format_enum in [TextureFormat.ARGB32, TextureFormat.RGBA32]:
405
print("Uncompressed RGBA texture")
406
elif format_enum.name.startswith("ASTC"):
407
print("ASTC compressed texture")
408
409
# Check if format is supported for export
410
supported_formats = [
411
TextureFormat.ARGB32,
412
TextureFormat.RGBA32,
413
TextureFormat.RGB24,
414
TextureFormat.DXT1,
415
TextureFormat.DXT5
416
]
417
418
if format_enum in supported_formats:
419
texture.save(f"exports/{texture.name}.png")
420
else:
421
print(f"Format {format_enum.name} may need special handling")
422
```
423
424
### Audio Format Detection
425
426
```python
427
import UnityPy
428
from UnityPy.enums import AudioType, AudioCompressionFormat, AUDIO_TYPE_EXTEMSION
429
430
env = UnityPy.load("audio_assets/")
431
432
for obj in env.objects:
433
if obj.type.name == "AudioClip":
434
audio = obj.read()
435
436
# Get audio format information
437
compression_format = audio.m_CompressionFormat
438
439
print(f"Audio: {audio.name}")
440
print(f"Compression: {compression_format.name}")
441
print(f"Length: {audio.m_Length:.2f}s")
442
print(f"Sample Rate: {audio.m_Frequency}Hz")
443
print(f"Channels: {audio.m_Channels}")
444
445
# Determine output format based on compression
446
if compression_format == AudioCompressionFormat.PCM:
447
output_ext = ".wav"
448
elif compression_format == AudioCompressionFormat.Vorbis:
449
output_ext = ".ogg"
450
elif compression_format == AudioCompressionFormat.MP3:
451
output_ext = ".mp3"
452
else:
453
output_ext = ".wav" # Default to WAV
454
455
try:
456
audio.save(f"exports/{audio.name}{output_ext}")
457
except Exception as e:
458
print(f"Failed to export: {e}")
459
```
460
461
### Platform and Build Target Information
462
463
```python
464
import UnityPy
465
from UnityPy.enums import BuildTarget
466
467
env = UnityPy.load("platform_specific_assets/")
468
469
# Check build target from serialized files
470
for filename, file_obj in env.files.items():
471
if hasattr(file_obj, 'target_platform'):
472
target = file_obj.target_platform
473
print(f"File: {filename}")
474
print(f"Target Platform: {target.name} ({target.value})")
475
476
# Handle platform-specific logic
477
if target == BuildTarget.Android:
478
print("Android-specific assets")
479
elif target == BuildTarget.iOS:
480
print("iOS-specific assets")
481
elif target in [BuildTarget.StandaloneWindows, BuildTarget.StandaloneWindows64]:
482
print("Windows-specific assets")
483
```
484
485
### Shader Platform Detection
486
487
```python
488
import UnityPy
489
from UnityPy.enums import ShaderCompilerPlatform, ShaderGpuProgramType
490
491
env = UnityPy.load("shader_assets/")
492
493
for obj in env.objects:
494
if obj.type.name == "Shader":
495
shader = obj.read()
496
497
print(f"Shader: {shader.name}")
498
499
# Access parsed shader form if available
500
if hasattr(shader, 'm_ParsedForm') and shader.m_ParsedForm:
501
parsed = shader.m_ParsedForm
502
503
# Check supported platforms
504
if hasattr(parsed, 'm_Platforms'):
505
platforms = parsed.m_Platforms
506
print("Supported platforms:")
507
for platform in platforms:
508
if isinstance(platform, ShaderCompilerPlatform):
509
print(f" - {platform.name}")
510
511
# Check GPU program requirements
512
if hasattr(parsed, 'm_SubShaders'):
513
for subshader in parsed.m_SubShaders:
514
if hasattr(subshader, 'm_Passes'):
515
for pass_data in subshader.m_Passes:
516
if hasattr(pass_data, 'm_ProgVertex'):
517
vertex_prog = pass_data.m_ProgVertex
518
if hasattr(vertex_prog, 'm_SubPrograms'):
519
for subprog in vertex_prog.m_SubPrograms:
520
if hasattr(subprog, 'm_GpuProgramType'):
521
gpu_type = subprog.m_GpuProgramType
522
print(f" GPU Program: {gpu_type.name}")
523
```
524
525
### Mesh and Vertex Format Analysis
526
527
```python
528
import UnityPy
529
from UnityPy.enums import VertexFormat, MeshTopology
530
531
env = UnityPy.load("mesh_assets/")
532
533
for obj in env.objects:
534
if obj.type.name == "Mesh":
535
mesh = obj.read()
536
537
print(f"Mesh: {mesh.name}")
538
print(f"Vertices: {len(mesh.vertices) if mesh.vertices else 0}")
539
540
# Check mesh topology
541
if hasattr(mesh, 'm_Topology'):
542
topology = mesh.m_Topology
543
if topology == MeshTopology.Triangles:
544
print("Triangle mesh")
545
elif topology == MeshTopology.Quads:
546
print("Quad mesh")
547
elif topology == MeshTopology.Lines:
548
print("Line mesh")
549
550
# Analyze vertex channels if available
551
if hasattr(mesh, 'm_VertexData') and mesh.m_VertexData:
552
vertex_data = mesh.m_VertexData
553
if hasattr(vertex_data, 'm_Channels'):
554
print("Vertex channels:")
555
for i, channel in enumerate(vertex_data.m_Channels):
556
if hasattr(channel, 'format') and channel.format != VertexFormat.Float:
557
print(f" Channel {i}: {channel.format.name}")
558
elif hasattr(channel, 'm_Format'):
559
format_val = channel.m_Format
560
if isinstance(format_val, VertexFormat):
561
print(f" Channel {i}: {format_val.name}")
562
```
563
564
### Bundle Compression Analysis
565
566
```python
567
import UnityPy
568
from UnityPy.enums import CompressionFlags
569
570
env = UnityPy.load("bundle_assets/")
571
572
for filename, file_obj in env.files.items():
573
if hasattr(file_obj, 'signature') and file_obj.signature == "UnityFS":
574
# This is a bundle file
575
print(f"Bundle: {filename}")
576
577
if hasattr(file_obj, 'm_Header'):
578
header = file_obj.m_Header
579
if hasattr(header, 'flags'):
580
flags = header.flags
581
582
# Extract compression type from flags
583
compression_type = flags & 0x3F # CompressionTypeMask
584
585
if compression_type == CompressionFlags.None.value:
586
print(" Compression: None")
587
elif compression_type == CompressionFlags.LZMA.value:
588
print(" Compression: LZMA")
589
elif compression_type == CompressionFlags.LZ4.value:
590
print(" Compression: LZ4")
591
elif compression_type == CompressionFlags.LZ4HC.value:
592
print(" Compression: LZ4HC")
593
else:
594
print(f" Compression: Unknown ({compression_type})")
595
```