Search code examples
unreal-engine4unreal-blueprint

Convert STRING name of texture to TEXTURE reference in blueprints


I have "Make Brush from Texture" node and I am able to select textures from the dropdown list in editor, but how I can set this texture field realtime from blueprint if its name is saved in the string variable (for example, "af"). Thanks.

Example:

https://blueprintue.com/blueprint/4indn35l/

SUGGESTION:

In theory, there should be an ARRAY with all loaded system textures that I can loop, compare the name of the texture one-by-one, and post the right texture to in-socket of "Make Brush from Texture".

Thanks!


Solution

  • You can do this by using soft object paths.

    • Create a Make Soft Object Path node
    • The Path String should be the full path of a valid texture. You can see what that should look like by right-clicking one of your textures in the asset browser, selecting 'Copy Reference', and pasting that into a text field.
    • Plug the result of the 'Make Soft Object Path' node into a 'Convert to Soft Object Reference` node.
    • Plug the result of that into a 'Resolve Soft Reference' node.
    • Plug the result of that into a 'Load Asset Blocking' or 'Async Load Asset' node.
    • Plug the result of that into a Cast To Texture2D node.
    • Plug the result of a successful cast into your Make Brush From Texture node.