Find texture and apply it to the material

Hello,

I have folder called Textures and inside that folder I have lot of textures (about 100) and I would like to dynamically apply it to the actor (mesh).

Problem is that I don’t know how to find texture from string. I know that I have to create Material Instance with param Texture and I can add texture to that param and then apply that Material to the mesh (actor).

But I don’t know how to find that texture. Imagine that you have function called ApplyTexture like this, and you have only string:

You won’t be able to find it by searching the folder hierarchy. You’ll want a list or table to reference that contains the textures with a unique identifier (could be a string, int, Name, etc).

You could do this with a Map or a Data Table, but I think a map is probably the simplest.

Like so:

But for example if I had 500 textures, then I had to manually each texture import to the Map?

If you want to do this all through Blueprint, I believe so. With C++, you may be able to find specific assets by file path. I haven’t done that before, but I’m sure it’s possible. You can read up on the Asset Manager and Asset Bundles as a possible starting point in getting and loading bundles of assets.

Alternatively, Data Tables and a script to write a CSV file for import might be able to accomplish a similar result, although I’m not sure if getting an asset reference that way is possible.

@t0msk: if you have this data in a spreadsheet, you could use a data table. You can fetch items by Row Name. Look up Structs and DataTables on YT to get the hang of it.

You could use a DT directly. Or you can use it to build a Map dynamically, like in dachora1’s example.

@dachora1 It can be found by searching the folder, you can use: