I want to assign different material instance for each StaticMeshComponent. First, set material for StaticMeshComponent, then set material.
I’ve tried different ways, set override_materials
property, or set_material(0, material)
. Nothing happened. Also, get_material_slot_names
returns []
, get_num_materials
returns 0
. but there are two material slots in the mesh asset.
children_components = root_component.get_children_components(False)
for child_component in children_components:
if not isinstance(child_component, unreal.StaticMeshComponent):
continue
components.append(child_component)
child_component.set_editor_property('static_mesh', mesh_asset)
print(child_component.get_material_slot_names())
print(child_component.get_num_materials())
child_component.set_editor_property('override_materials', [material_example, material_example])