# Setting Material Slot Names on Static Mesh Materials not updating Editor UI

**URL:** <https://forums.unrealengine.com/t/setting-material-slot-names-on-static-mesh-materials-not-updating-editor-ui/559681>\
**Category:** Editor Scripting\
**Tags:** Python, unreal-engine, UE5-0, question\
**Created:** [May 17, 2022, 8:59pm UTC](https://forums.unrealengine.com/t/setting-material-slot-names-on-static-mesh-materials-not-updating-editor-ui/559681 "2022-05-17T20:59:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ePacel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ePacel](https://forums.unrealengine.com/u/ePacel)\
**Post date:** [May 17, 2022, 8:59pm UTC](https://forums.unrealengine.com/t/setting-material-slot-names-on-static-mesh-materials-not-updating-editor-ui/559681/1 "2022-05-17T20:59:22Z")

</div>

I’m trying to rename the material slots on the selected static meshes in the content browser. If I run the script below it works if I get the editor property and print it to log after settings it, but it doesn’t update the “Slot Name” field in the editor for the material on the selected static meshes.

> **[Scripting the Unreal Editor Using Python](https://docs.unrealengine.com/5.0/en-US/scripting-the-unreal-editor-using-python/)**
>
> Describes how to use Python in the Unreal Editor to script content production tasks.

The documentation says that using “set\_editor\_property” will force the editor UI update but it’s not in this case. Any idea’s what I’m doing wrong?

```auto
  selectedAssetsPaths = unreal.EditorUtilityLibrary().get_selected_assets()
  for asset in selectedAssetsPaths:
      materials = asset.get_editor_property("static_materials")
      for mat in materials:      
          mat.set_editor_property("material_slot_name", "New Slot Name!")

```

---

<div class="post-metadata">

**Author:** ![ePacel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ePacel](https://forums.unrealengine.com/u/ePacel)\
**Post date:** [May 18, 2022, 11:04am UTC](https://forums.unrealengine.com/t/setting-material-slot-names-on-static-mesh-materials-not-updating-editor-ui/559681/2 "2022-05-18T11:04:21Z")

</div>

This was resolved in a post off this forum. Putting the answer here for anyone else that needs it.

"It seems that for whatever reason, it keeps overwriting the changes immediately after they are made (like it is force reloading the asset from the editor). I was able to find a way around this by making a copy of the materials and changing that copy, before reassigning it back into the asset.

This seems to work for me. Note: for some reason I had to also reassign the mateial back into the array or again it would overwrite itself"

```auto
selectedAssetsPaths = unreal.EditorUtilityLibrary().get_selected_assets()
for asset in selectedAssetsPaths:
	mats = asset.static_materials.copy()
	for i, mat in enumerate(mats):
		mat.material_slot_name = "New Slot Name!"
		mats[i] = mat
	asset.static_materials = mats

```

---

<div class="post-metadata">

**Author:** ![Pixel\_Punk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pixel\_Punk](https://forums.unrealengine.com/u/Pixel_Punk)\
**Post date:** [October 19, 2023, 3:31pm UTC](https://forums.unrealengine.com/t/setting-material-slot-names-on-static-mesh-materials-not-updating-editor-ui/559681/3 "2023-10-19T15:31:37Z")

</div>

Thank you so much! Took me 2 hours of sanity checks to figure this out 😅

Btw if you want to change the material in the renamed slot, you have to assign it in the same loop with `mat.set_editor_property('material_interface', newMaterial)`
