How to locate and access a texture on file from a blueprint

Hi All,

I’m trying to figure out how to get a texture asset on disk and cast it to a Texture2D using blueprints.

In the screenshot I have a bunch of debugs, but It’s finding the texture and showing it as valid. However, it won’t cast to Texture2D or even Texture (the cast always fails).

The Object Path that’s going into the ‘Get Asset by Object Path’ is in the format: /Game/TestFolder/WoodenCrate_Albedo

I don’t put the .png or .uasset on it as that doesn’t work. But this format finds a valid asset but won’t cast it to a texture2D which is what I need to do with it.

Any ideas how I can cast it to a Texture2D? Thx

Hey @HappyKat100,

This tutorial appears to be similar to what you are looking for. Have you already tried setting a texture2D variable instead?

Hi @Quetzalcodename - Thanks for the reply. This video refers to downloading an image from a URL and then that node gives the Texture object output. I already have a texture in my contents folder and need to identify it and get it as a texture object. So the Download Image node won’t work as it’s looking for a URL.

Also, I tested the “Download Image” Node and I can force it to find a local file… however it returns a Dynamic Object Reference and I want the actual static object reference as I’m plugging it into a material constant not a material dynamic.

Any help would be appreciated!

Ok, found the solution in this thread…

https://www.reddit.com/r/unrealengine/comments/s3nlub/get_texture_by_asset_path_and_set_it_as_widget/

Essentially the filepath should be:

Texture2D’/Game/FolderA/FolderB/My_Texture.My_Texture’

Would have never guessed this in a million years so leaving here for future searchers!

Thanks!

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