Is there a way to get an asset (not currently in the level, but part of the project) by name, using a string?
For example, using the string ‘Someones_Name’ I would like to be able to get a Media Player reference with that name, and then append ‘_Tex_Mat’ to the string (creating ‘Someones_Name_Tex_Mat’) and grab a material using that name.
The reason I’m trying to do this is I have many hundreds of video files that I want to assign at runtime to custom objects. Doing this manually will take ages, so I was hoping to bring in a Data Table full of string names which a function can then read from to generate these objects.
Thus far, I cannot find any way to do this – is this even possible?
Can you elaborate on that a little? I have successfully imported a list of the asset names from csv into a datatable, so I have access to that list at runtime. But all I have is a list of strings, and I can’t seem to find any way to use those strings to, for example, call up a particular asset (Media Player or Material in this case).
I know I could make an array by hand which had all the Media Players and Materials in, but that defeats the point as adding 500+ objects each to two arrays is the thing I’m trying to avoid.
However, when you have the names already as strings, then you can just loop through all your media players (all actors of class) and assign the media references there.
Hmm, that’s not exactly it unfortunately. That seems to be a way to get a particular class by it’s name, unless I’m misunderstanding it. What I want is to get hold of a particular asset of a class by it’s name.
Essentially, let’s say I have a folder in my content called ‘Materials’ containing a whole load of materials:
Material_Tex_Mat_001
Material_Tex_Mat_002
Material_Tex_Mat_003
Material_Tex_Mat_004
Material_Tex_Mat_005
etc.
What I want is a Blueprint node that I can enter the string name for one of these materials (eg. ‘Material_Tex_Mat_03’) and get the actual material reference returned.
Note that these materials do not exist in the level as actors, they are simply materials in the content of the project.
If I’m understanding correctly what you want to do, you can make a csv file with 2 values, the first being Name and the second being Material. The first column would be the name of the material, and the 2nd would be the actual path to it, for example, something like:
and then in Unreal, make a struct that has 1 variable, type of Material.
Then drag the csv file into unreal and when it asks for the struct type choose the struct you created.
Then in your bp, when you want to access that material, you right click and use a node called Get Data Table Row, and click the Select Asset and choose the name of the csv file you imported, and in the row name, pass in the name of the row that had the material. You should be able to break the out row and get your material that way.