Creating/Updating Texture2D from Texture in runtime

I found many questions/answers where people asked how to create Texture2D in runtime. What I didn’t find (at all) is an explanation of how to create or update an existing Texture2D from Texture object. Here is a use case:

UMG widget with image widget which has a default brush with Texture2D assigned via the editor. In runtime I want to load a Texture asset from my asset lib and update that Texture2D. Yes,I can create a new brush and replace the existing one. But I would like to just update the texture. And I didn’t find a way how to do that. Casting Texture to Texture2D doesn’t work as the later subclasses the former. Texture2D has no interface even in C++ to accept a Texture Object in runtime. So it seems like Texture2D can be updated only by a raw data and created from scratch, again, from a raw pixel data? Then why we have all those Texture assets in runtime if we can’t make Texture2D objects out of them?

I probably asked too many questions at once. I am not really interested in brushes specifically as there are functions that allow to update those from textures. My question is more generic. How do I update/create a Texture2D in runtime from Texture asset. In runtime, not in the editor and not related to UMG styles. Thanks.

I might have misunderstood the intent but you can update the Image’s brush with Texture 2D:

336346-screenshot-2.png

Alternatively, you could parametrise a UI material and:

Would any of that

I probably asked too many questions at once. I am not really interested in brushes specifically as there are functions that allow to update those from textures. My question is more generic. How do I update/create a Texture2D in runtime from Texture asset. In runtime, not in the editor and not related to UMG styles. Thanks.

did you found the answer to this question?