I have been adding soft references to my project and had been using the “Async Load Asset” node to utilize the references. This involved casting to the particular type of asset i need.
However I just came across this node SetBrushfromSoftTexture while setting up texture references in a widget and it seems to do exactly the same thing without having to manually load it to memory or cast the asset. it just works.
So, is this just what i had been doing put into a single node? Is there something special about images that just makes this work? i tested it on my phone and it worked fine. any clarification on what this does would be greatly appreciated, can’t find much information right now and i have a lot of images to handle…
I know this is old but I just came looking for the same answer and decided to read the engine code to clarify.
It’s basically just calling AsyncLoadAsset (aka RequestAsyncLoad) for you and is just a helper function for this purpose.
From UE 5.2:
void UImage::SetBrushFromSoftTexture(TSoftObjectPtr<UTexture2D> SoftTexture, bool bMatchSize)
{
TWeakObjectPtr<UImage> WeakThis(this); // using weak ptr in case 'this' has gone out of scope by the time this lambda is called
RequestAsyncLoad(SoftTexture,
[WeakThis, SoftTexture, bMatchSize]() {
if (UImage* StrongThis = WeakThis.Get())
{
ensureMsgf(SoftTexture.Get(), TEXT("Failed to load %s"), *SoftTexture.ToSoftObjectPath().ToString());
StrongThis->SetBrushFromTexture(SoftTexture.Get(), bMatchSize);
}
}
);
}