Skip to main content

unityrs_texture/format/
names.rs

1// Ported from UnityPy 1.25.2 (MIT): UnityPy/enums/TextureFormat.py (the member names and values). See THIRD_PARTY_LICENSES.
2//! Every named Unity texture format, including formats without decoders.
3
4/// UnityPy 1.25.2's `TextureFormat` members, value and name, in its order
5/// (`enums/TextureFormat.py:4-82`). Values 37 to 40 are unassigned.
6pub const TEXTURE_FORMATS: [(i32, &str); 78] = [
7    (1, "Alpha8"),
8    (2, "ARGB4444"),
9    (3, "RGB24"),
10    (4, "RGBA32"),
11    (5, "ARGB32"),
12    (6, "ARGBFloat"),
13    (7, "RGB565"),
14    (8, "BGR24"),
15    (9, "R16"),
16    (10, "DXT1"),
17    (11, "DXT3"),
18    (12, "DXT5"),
19    (13, "RGBA4444"),
20    (14, "BGRA32"),
21    (15, "RHalf"),
22    (16, "RGHalf"),
23    (17, "RGBAHalf"),
24    (18, "RFloat"),
25    (19, "RGFloat"),
26    (20, "RGBAFloat"),
27    (21, "YUY2"),
28    (22, "RGB9e5Float"),
29    (23, "RGBFloat"),
30    (24, "BC6H"),
31    (25, "BC7"),
32    (26, "BC4"),
33    (27, "BC5"),
34    (28, "DXT1Crunched"),
35    (29, "DXT5Crunched"),
36    (30, "PVRTC_RGB2"),
37    (31, "PVRTC_RGBA2"),
38    (32, "PVRTC_RGB4"),
39    (33, "PVRTC_RGBA4"),
40    (34, "ETC_RGB4"),
41    (35, "ATC_RGB4"),
42    (36, "ATC_RGBA8"),
43    (41, "EAC_R"),
44    (42, "EAC_R_SIGNED"),
45    (43, "EAC_RG"),
46    (44, "EAC_RG_SIGNED"),
47    (45, "ETC2_RGB"),
48    (46, "ETC2_RGBA1"),
49    (47, "ETC2_RGBA8"),
50    (48, "ASTC_RGB_4x4"),
51    (49, "ASTC_RGB_5x5"),
52    (50, "ASTC_RGB_6x6"),
53    (51, "ASTC_RGB_8x8"),
54    (52, "ASTC_RGB_10x10"),
55    (53, "ASTC_RGB_12x12"),
56    (54, "ASTC_RGBA_4x4"),
57    (55, "ASTC_RGBA_5x5"),
58    (56, "ASTC_RGBA_6x6"),
59    (57, "ASTC_RGBA_8x8"),
60    (58, "ASTC_RGBA_10x10"),
61    (59, "ASTC_RGBA_12x12"),
62    (60, "ETC_RGB4_3DS"),
63    (61, "ETC_RGBA8_3DS"),
64    (62, "RG16"),
65    (63, "R8"),
66    (64, "ETC_RGB4Crunched"),
67    (65, "ETC2_RGBA8Crunched"),
68    (66, "ASTC_HDR_4x4"),
69    (67, "ASTC_HDR_5x5"),
70    (68, "ASTC_HDR_6x6"),
71    (69, "ASTC_HDR_8x8"),
72    (70, "ASTC_HDR_10x10"),
73    (71, "ASTC_HDR_12x12"),
74    (72, "RG32"),
75    (73, "RGB48"),
76    (74, "RGBA64"),
77    (75, "R8_SIGNED"),
78    (76, "RG16_SIGNED"),
79    (77, "RGB24_SIGNED"),
80    (78, "RGBA32_SIGNED"),
81    (79, "R16_SIGNED"),
82    (80, "RG32_SIGNED"),
83    (81, "RGB48_SIGNED"),
84    (82, "RGBA64_SIGNED"),
85];
86
87/// UnityPy 1.25.2's name for a `TextureFormat` value, or `None` for a value
88/// its enum lacks (where `TextureFormat(value)` raises `ValueError`).
89#[must_use]
90pub fn texture_format_name(value: i32) -> Option<&'static str> {
91    TEXTURE_FORMATS
92        .iter()
93        .find(|(v, _)| *v == value)
94        .map(|(_, name)| *name)
95}