Loading and Using New Assets at Runtime

I would like the player to be able to use their own artwork for the avatar and some other assets. Maybe Have them enter the file path and name then have it load in game. Or have a designated folder that you just drop an .jpg into and it automatically uses it. How would I go about doing this?

    • Finding the file
    • Creating an asset with the file at runtime (if that is what’s needed)
    • Using the file in game

Hey there @Seed_37! So it’s dependent on if you just want a texture2D or not. If that’s all you want, the Import File as Texture 2D node will do just fine. It returns a Texture2D with the image.

image

Then here’s the C++ variant for those who need it:

FString FilePath = "C:/Users/MyUser/Images/MyImage.png";
UTexture2D* MyTexture = FImageUtils::ImportFileAsTexture2D(FilePath);

That said, having the player input file paths is… tedious to say the least. So here’s a free marketplace plugin by Firefly Studio that let’s you look directly for a filepath in an OS window. I believe it’s windows only however so you’d have to expand it by hand if you support other OSes.

This is not an endorsement by Epic Games, I just use this plugin and I love it

Let me know if you have any questions!

Thank you very much for the information on this, I will be trying it out as soon as I can get to it.

1 Like