I would like to set a series of buttons for your inventory that are text blocks, each of which spawn a static mesh in the world. What I would like is to create a series of materials named, for example: Rock, Paper, Scissors. I would like then to pass the text for the button to the Mesh spawner and set the Material of the mesh to a texture matching the string.
So, the token for Rock, would be built to say the word “rock” in the inventory, and when clicked spawns a static mesh with a material set to “rock” as well.
Is this possible? Or should I set up a humongous switch (I have 100 objects at the moment, and will eventually have 700) that chooses the texture based on “switch on name”?
How I would do it is to have the button call an event and pass through its text as a string. The event would check materials in a material array and compare the material names to the string that the button passed through. if the name is the same then call another event that takes in a material as an argument and spawns the object you want then applies said material to it. Then break the foreach loop.
Yes that looks like it would work, I’d still have to set the Mats array with about 100 entries, but that’s better than making an 100 part switch. I’ll let you know how it works out in a few.
If you know a little C++ it’d be much faster to create a node that loads all the materials into said array from a path
I know a little, but very little. Basic concepts not any real implementation, enough that it helps learn blueprint at any rate. Your method worked like a charm by the way. I’m appending the Button Name string with “M_” so I can keep my file structure sane and it still functions smoothly.
Awesome! Glad to help!