Set Material Slot Names in Blueprint

Question is as simple as it gets.
I know I can go inside of a static mesh to find its material slots and rename them. But I wanna do it procedurally via blueprint. There is “Get Material Slot Names” but not SET Material Slot Names.
I basically wanna mass assign random materials based on the material they are suppsed to replace, and for the first time doing that, I can theoretically just look for the name of the material that I wanna replace. But once that’s done, I can’t use that method a second time.
I tried playing around with tags, but that’s also flawed for this cause.

The easiest way would be to just go by Material Slot Names, but for some reason I can’t rename those in Blueprint. Or can I? Any Ideas?

Thanks in Advance!

Hey there @Yoosten! Would you be attempting to replace these names at runtime? As I don’t believe that variable is exposed to be changed at runtime at all. I’ve seen a couple of users that created editor blueprints to be able to modify them. I’ll leave a thread with a bit of information on that at least. Hope this helps!

Hello there!
No, I’m trying to set them via Editor Utility Widget. The Thread you linked is sadly for Python Users, and I can’t find an option to create said copy in Blueprint.
Any idea how I can handle this in Blueprint and in the editor?

Aight, I found my solution:


This won’t work for people that additionally put default tags on their Meshes, but I just check if the selected Actor has Tags. If it doesn’t, I add its Default Materials as Tags to it. If it already has Tags, I check if any of them match the Material Name I’m specifying. If any do, I can just take the Tag Index (which matches the Material Index) and replace the Material in said Index.

that said, I just noticed that this won’t work in Cases where 2 Slots contain the same Material. I’ll quickly fix that, but that’ll be simple enough so that I won’t update this post anymore.
I hope this helped anyone who wanted to do similar things :>

1 Like

Apparently I’m not a Man of my Word.
Here’s the updated portion of the Graph:

2 Likes

Oh wow fantastic! I was trying to work up a C++ set up for you but it seems you got it in BP no less! Amazing. Do you mind if I reference this setup for a possible Community Snippet in the future? One question that absolutely stumped me for a moment.

Creative solution, it’s a shame we can’t directly set the material slot names though, would be super helpful to do this in batches.

EDIT: So it turns out it is possible. I was editing using the bulk property matrix, and found the structure containing the data. Here’s what the code looks like:

Ignore the spaghetti, works as intended though. This is for skeletal meshes, but I imagine there’s a similar property for static.