Get Material Slot Name for Static Mesh


I’m currently using a python script to import an fbx and create a Static Mesh.

My current asset I’m testing has 4 materials, which have the correct slot name, but the actual material name gets set to “WorldGameMaterial”.

If I set “import_materials” to true, it sets the name properly, but I don’t want the materials imported.

Does anyone know how to get the material slot names for a static mesh?


Here’s the solution:

static_mesh = unreal.load_asset(static_mesh_path)
static_mesh_component = unreal.StaticMeshComponent()
material_slot_names = unreal.StaticMeshComponent.get_material_slot_names(static_mesh_component)

Sorry to revive this post but how would you set the material of that static mesh?

Late response but: unreal.StaticMesh has a “set_material()” function.
It doesn’t take the name of the material slot though, it takes the index.

I’m basically doing:

material_index = static_mesh.get_material_index(material.get_name())
static_mesh.set_material(material_index, material)

This assumes the material name is the same as the material slot on the static mesh though.