# set\_material of StaticMeshComponent doesn't work in python

**URL:** <https://forums.unrealengine.com/t/set-material-of-staticmeshcomponent-doesnt-work-in-python/727235>\
**Category:** Programming & Scripting\
**Tags:** Python, unreal-engine, question\
**Created:** [December 13, 2022, 10:22am UTC](https://forums.unrealengine.com/t/set-material-of-staticmeshcomponent-doesnt-work-in-python/727235 "2022-12-13T10:22:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![liyangyang0901](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@liyangyang0901](https://forums.unrealengine.com/u/liyangyang0901)\
**Post date:** [December 13, 2022, 10:22am UTC](https://forums.unrealengine.com/t/set-material-of-staticmeshcomponent-doesnt-work-in-python/727235/1 "2022-12-13T10:22:51Z")

</div>

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.

```auto
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])

```
