Setting Materials with a String

We are working on an application that has over 1000 materials in the unreal project.

I was wondering if it was possible if I had the path to the material, if it would be possible to set an Actor’s materials using a String for the material name and/or path. I have it working with a map, having the string reference a specific material, but this isn’t optimal for us if we want to add more materials and was hoping someone knew a better way of doing this.

This could work for you:

https://forums.unrealengine.com/deve…97#post1490197

Alternatively, you could keep the paths in a DataTable and use that or build a Map dynamically.

The link you provided was perfect! Thank you!

having the same issue, but can’t find a solution

seems to be working now, but i’m not sure

Yes, that works, but you may want to cast to material interface instead so that it can also take material instances (you can see that the set material node takes a material interface).

thanks, i already figured it out, i guess it was a bug lol - it only see materials and not m_instance

why i should use material interface instead ?

Screenshot_20211012_005034

To support both materials and material instances (they are both material interfaces); the SetMaterial node takes a material interface for this reason.

1 Like

oh, got it, thanks!

i’ll better stay with mi :smile:

1 Like