Skip to main content

unityrs_core/objmode/
classes.rs

1// Ported from UnityPy 1.25.2 (MIT): UnityPy/classes/generated.py, object-mode class fields. See THIRD_PARTY_LICENSES.
2// Ported from UnityPy git 417d595 (MIT): UnityPy/classes/generated.py, the Mesh class. See THIRD_PARTY_LICENSES.
3/// A class's attrs fields (`classes/generated.py`), and whether object
4/// mode builds it as an `UnknownObject` when given a field it lacks
5/// (`PARITY.md` section 9.2.1: a non-empty `__slots__`).
6#[derive(Debug)]
7pub struct Class {
8    /// The node types that look this class up (a node's `m_Type`).
9    pub types: &'static [&'static str],
10    /// Fields without a default.
11    pub required: &'static [&'static str],
12    /// Fields whose default is `None`.
13    pub optional: &'static [&'static str],
14    /// A non-empty `__slots__`: an extra field gives an `UnknownObject`.
15    pub slotted: bool,
16}
17
18/// `Mesh` (`classes/generated.py:4605-4642`), whose `__slots__` is `()`.
19pub const MESH: Class = Class {
20    types: &["Mesh"],
21    required: &[
22        "m_BindPose",
23        "m_CompressedMesh",
24        "m_IndexBuffer",
25        "m_LocalAABB",
26        "m_MeshCompression",
27        "m_MeshUsageFlags",
28        "m_Name",
29        "m_SubMeshes",
30    ],
31    optional: &[
32        "m_BakedConvexCollisionMesh",
33        "m_BakedTriangleCollisionMesh",
34        "m_BoneNameHashes",
35        "m_BonesAABB",
36        "m_CollisionTriangles",
37        "m_CollisionVertexCount",
38        "m_Colors",
39        "m_CookingOptions",
40        "m_IndexFormat",
41        "m_IsReadable",
42        "m_KeepIndices",
43        "m_KeepVertices",
44        "m_MeshLodInfo",
45        "m_MeshMetrics_0_",
46        "m_MeshMetrics_1_",
47        "m_Normals",
48        "m_RootBoneNameHash",
49        "m_ShapeVertices",
50        "m_Shapes",
51        "m_Skin",
52        "m_StreamCompression",
53        "m_StreamData",
54        "m_Tangents",
55        "m_UV",
56        "m_UV1",
57        "m_Use16BitIndices",
58        "m_VariableBoneCountWeights",
59        "m_VertexData",
60        "m_Vertices",
61    ],
62    slotted: false,
63};
64
65/// `Mesh` from Unity 6000 (Tier C, `PARITY.md` section 19.1): UnityPy git
66/// 417d595's fields (`HEAD classes/generated.py:4813-4852`, unchanged at
67/// master), from a newer TPK: `m_MeshUsageFlags`,
68/// which Unity 6000.6 no longer writes, has the default `None`, and the two
69/// `m_PreBake*` flags are new. 1.25.2 requires it, so builds an `UnknownObject`.
70pub const MESH_6000: Class = Class {
71    types: &["Mesh"],
72    required: &[
73        "m_BindPose",
74        "m_CompressedMesh",
75        "m_IndexBuffer",
76        "m_LocalAABB",
77        "m_MeshCompression",
78        "m_Name",
79        "m_SubMeshes",
80    ],
81    optional: &[
82        "m_BakedConvexCollisionMesh",
83        "m_BakedTriangleCollisionMesh",
84        "m_BoneNameHashes",
85        "m_BonesAABB",
86        "m_CollisionTriangles",
87        "m_CollisionVertexCount",
88        "m_Colors",
89        "m_CookingOptions",
90        "m_IndexFormat",
91        "m_IsReadable",
92        "m_KeepIndices",
93        "m_KeepVertices",
94        "m_MeshLodInfo",
95        "m_MeshMetrics_0_",
96        "m_MeshMetrics_1_",
97        "m_MeshUsageFlags",
98        "m_Normals",
99        "m_PreBakeConvexCollisionMesh",
100        "m_PreBakeTriangleCollisionMesh",
101        "m_RootBoneNameHash",
102        "m_ShapeVertices",
103        "m_Shapes",
104        "m_Skin",
105        "m_StreamCompression",
106        "m_StreamData",
107        "m_Tangents",
108        "m_UV",
109        "m_UV1",
110        "m_Use16BitIndices",
111        "m_VariableBoneCountWeights",
112        "m_VertexData",
113        "m_Vertices",
114    ],
115    slotted: false,
116};
117
118/// `Sprite` (`classes/generated.py:4867-4882`), whose `__slots__` is `()`.
119pub const SPRITE: Class = Class {
120    types: &["Sprite"],
121    required: &[
122        "m_Extrude",
123        "m_Name",
124        "m_Offset",
125        "m_PixelsToUnits",
126        "m_RD",
127        "m_Rect",
128    ],
129    optional: &[
130        "m_AtlasTags",
131        "m_Bones",
132        "m_Border",
133        "m_IsPolygon",
134        "m_PhysicsShape",
135        "m_Pivot",
136        "m_RenderDataKey",
137        "m_ScriptableObjects",
138        "m_SpriteAtlas",
139    ],
140    slotted: false,
141};
142
143/// `SpriteRenderData` (`classes/generated.py:10903-10919`).
144pub const SPRITE_RENDER_DATA: Class = Class {
145    types: &["SpriteRenderData"],
146    required: &["settingsRaw", "texture", "textureRect", "textureRectOffset"],
147    optional: &[
148        "alphaTexture",
149        "atlasRectOffset",
150        "downscaleMultiplier",
151        "indices",
152        "m_Bindpose",
153        "m_IndexBuffer",
154        "m_SourceSkin",
155        "m_SubMeshes",
156        "m_VertexData",
157        "secondaryTextures",
158        "uvTransform",
159        "vertices",
160    ],
161    slotted: true,
162};
163
164/// `VertexData` (`classes/generated.py:11800-11809`).
165pub const VERTEX_DATA: Class = Class {
166    types: &["VertexData"],
167    required: &["m_DataSize", "m_VertexCount"],
168    optional: &[
169        "m_Channels",
170        "m_CurrentChannels",
171        "m_Streams",
172        "m_Streams_0_",
173        "m_Streams_1_",
174        "m_Streams_2_",
175        "m_Streams_3_",
176    ],
177    slotted: true,
178};
179
180/// `ChannelInfo` (`classes/generated.py:7213-7217`).
181pub const CHANNEL_INFO: Class = Class {
182    types: &["ChannelInfo"],
183    required: &["dimension", "format", "offset", "stream"],
184    optional: &[],
185    slotted: true,
186};
187
188/// `StreamInfo` (`classes/generated.py:11043-11049`).
189pub const STREAM_INFO: Class = Class {
190    types: &["StreamInfo"],
191    required: &["channelMask", "offset", "stride"],
192    optional: &["align", "dividerOp", "frequency"],
193    slotted: true,
194};
195
196/// `SubMesh` (`classes/generated.py:11098-11107`).
197pub const SUB_MESH: Class = Class {
198    types: &["SubMesh"],
199    required: &[
200        "firstByte",
201        "firstVertex",
202        "indexCount",
203        "localAABB",
204        "vertexCount",
205    ],
206    optional: &["baseVertex", "isTriStrip", "topology", "triangleCount"],
207    slotted: true,
208};
209
210/// `StreamingInfo` (`classes/generated.py:11067-11070`).
211pub const STREAMING_INFO: Class = Class {
212    types: &["StreamingInfo"],
213    required: &["offset", "path", "size"],
214    optional: &[],
215    slotted: true,
216};
217
218/// `CompressedMesh` (`classes/generated.py:7488-7501`).
219pub const COMPRESSED_MESH: Class = Class {
220    types: &["CompressedMesh"],
221    required: &[
222        "m_BoneIndices",
223        "m_NormalSigns",
224        "m_Normals",
225        "m_TangentSigns",
226        "m_Tangents",
227        "m_Triangles",
228        "m_UV",
229        "m_Vertices",
230        "m_Weights",
231    ],
232    optional: &["m_BindPoses", "m_Colors", "m_FloatColors", "m_UVInfo"],
233    slotted: true,
234};
235
236/// `PackedBitVector` (`classes/generated.py:9160-9165`).
237pub const PACKED_BIT_VECTOR: Class = Class {
238    types: &["PackedBitVector"],
239    required: &["m_Data", "m_NumItems"],
240    optional: &["m_BitSize", "m_Range", "m_Start"],
241    slotted: true,
242};
243
244/// A skin element: `BoneWeights4` or `BoneInfluence`, the same fields
245/// (`classes/generated.py:6956-6976`); `m_Skin` is a list of either.
246pub const BONE_WEIGHTS: Class = Class {
247    types: &["BoneWeights4", "BoneInfluence"],
248    required: &[
249        "boneIndex_0_",
250        "boneIndex_1_",
251        "boneIndex_2_",
252        "boneIndex_3_",
253        "weight_0_",
254        "weight_1_",
255        "weight_2_",
256        "weight_3_",
257    ],
258    optional: &[],
259    slotted: true,
260};
261
262const _: () = crate::send_sync::<Class>();