remap_material_ids
Merge or compact MaterialIDs on a DynamicMeshActor's live mesh to close ID gaps that waste material slots when baking to a static mesh.
Instructions
Renumber MaterialIDs on a DynamicMeshActor's live dynamic mesh. Two modes: pass from_material_id + to_material_id to merge one ID into another (UGeometryScriptLibrary_MeshMaterialFunctions::RemapMaterialIDs), or pass compact=true with the material list to close gaps left by deleted/merged IDs (CompactMaterialIDs) and get back the compacted list to hand to copy_dynamic_mesh_to_static_mesh. Gaps matter: MaterialIDs index into that list positionally, so an unused ID in the middle costs a wasted material slot on the baked asset. The materials list may be shorter than the IDs in use (or absent): the missing entries count as no material. When no triangle carries from_material_id, or from and to are the same ID, the mesh is left unchanged and the call succeeds with applied false, triangles_remapped 0 and a note. Otherwise applied is measured (remap: the triangles that carried from_material_id no longer do; compact: the engine reported no error) and the call fails when it is false.
Returns: { actor_name, mode: string, from_material_id: int, to_material_id: int, triangles_remapped?: int, max_material_id_after: int, distinct_material_ids_after: int, compacted_materials: [string], applied: bool, note?: string }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| compact | No | Compact mode: renumber IDs to be contiguous from 0 (default false). | |
| materials | No | Compact mode: ordered UMaterialInterface content paths, one per current MaterialID. The compacted list is returned in compacted_materials, in the new ID order. | |
| actor_name | Yes | Label or name of the target DynamicMeshActor. | |
| to_material_id | No | Remap mode: the MaterialID to replace it with. Required unless compact is true. | |
| from_material_id | No | Remap mode: the MaterialID to replace. Required unless compact is true. | |
| remove_duplicate_materials | No | Compact mode: also merge IDs that point at the SAME material asset (default false). |