How to access a file from blueprint?

I’m trying to create an array of all textures in a specific content folder in blueprints.

But I cannot figure out how to get the list of those files in the first place, nevermind add them to the array.

How could I do this?

Edit: See implementation of solution here: How to access a file from blueprint? - #7 by Cestarian

Would this work:

Technically that works yes (thanks for that great trick), but it’s not ideal, it’d be much better if I could fetch all the files from a folder and add to an array procedurally.

The reason is I basically split a handful of GIFs into PNGs, and I’m animating them by swapping out the textures on a timeline, and i want to be able to switch between those gifs. If I do it this way i’d have to manually create a separate array for each gif rather than just fetching the required textures for one of them when it’s called for procedurally which is what I actually want to do.

Keep the assets in a data table. You can then categorise and fetch as you see fit.

1 Like

there is a get assets by path node.
Get Assets by Path in blueprint + Load level by naming convention (notion.site)

1 Like

this seems to be what i’m looking for except how do I convert asset data structure to texture2d?

@Everynone data table seems like the right way to do this sort of thing (i knew about them but somehow forgot, doh) but since i set out to do it a certain way I want to at least see if I can, it is potentially valuable knowledge anyhow, if you know a way to procedurally fill the datatable however, I will accept that answer.

I basically got what i wanted.
output

using data tables:

I tried the get assets by path approach too:


I got it to a point where it lists the names of the files in alphabetical order and stopped there cuz i saw that it was a hideous mess, owing partly to the fact that alphabetical sorting sorts things like 11, 12 and 13 right after 1, so instead of x-1,x-2,x-3 i get x-1,x-10,x-11… which is what lead to that convoluted mess at the bottom.

The way I’d have gone from here if I wanted to stick with it would be to instead of using an array, use a map which maps each texture to a name, using the names as keys i’d then sort them the same way as I did in the above code but instead of printing i’d get their values instead (which would be the textures) but running so many loops constantly when it could be avoided just bothers me so I went with the data table approach, i’m gonna accept that solution.

yeah to get thigns from a folder requires certain naming convention. But the trade off is that if you are changing those assets frequently, this way you wouldn’t need to update references in a data table. So; it’s just pros and cons to either approach.
working with strings and arrays in blueprint is a big pain in the butt though

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.