FStreamableDelegate OnAssetsLoadedDelegate = FStreamableDelegate::CreateUObject(this, &ThisClass::OnExperienceLoadComplete);
if (!Handle.IsValid() || Handle->HasLoadCompleted())
{
// Assets were already loaded, call the delegate now
FStreamableHandle::ExecuteDelegate(OnAssetsLoadedDelegate);
}
else
{
Handle->BindCompleteDelegate(OnAssetsLoadedDelegate);
Handle->BindCancelDelegate(FStreamableDelegate::CreateLambda([OnAssetsLoadedDelegate]()
{
OnAssetsLoadedDelegate.ExecuteIfBound();
}));
}
In the else part, why lambda is bound to the cancel delegate of the FStreamableHandle?
The delegates passed into BindCompleteDelegate() and BindCancelDelegate() are “copied”. So even when the load is complete, the original OnAssetsLoadedDelegate is still be the same.
I wonder why ExecuteIfBound is called to check if the original delegate (which is unaffected) is unbound.
Thank you