之前做项目可以很轻松的获取skeletal mesh的材质插槽,但是静态mesh没有同样的功能。
于是在google 搜到了一个答案,在此记录一下:
Ok, so the function get_material_slot_names() is a method of the StaticMeshComponent class. So you are able to retrieve the materials from base StaticMesh class by first creating a StaticMeshComponent, setting your asset as the static mesh property, then calling get_material_slot_names()
I wrote a simple function to do this:
def get_material_slot_names(static_mesh):
sm_component = unreal.StaticMeshComponent()
sm_component.set_static_mesh(static_mesh)
return unreal.StaticMeshComponent.get_material_slot_names(sm_component)
It seems a bit hacky to have to create a static mesh component just to access the material slots of the mesh itself, but this seems to work well enough for my purposes.