Skip to content

Instantly share code, notes, and snippets.

@tmsampson
Last active September 23, 2022 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmsampson/96648274b78103067bf8360597e493e6 to your computer and use it in GitHub Desktop.
Save tmsampson/96648274b78103067bf8360597e493e6 to your computer and use it in GitHub Desktop.
//----------------------------------------------------------------------------------------------------------
// Overview
//----------------------------------------------------------------------------------------------------------
// Below is a modified version of the vanilla UE5 function FLinkerLoad::CreateExportAndPreload which
// allows you to set a breakpoint which catches the loading of a specific asset (in this case "MyAsset").
//
// NOTE: Lines which have been added to the vanilla version of this method are tagged as "// << New"
//
// NOTE: Here we also force bForcePreload to true when encountering the asset, which causes the PreLoad
// function to be called immediately and synchronously (which is handy if you next want to debug
// serialisation logic for the asset without having to catch this on a separate thread).
//
// NOTE: If you want to catch the asset loading even earlier, add the following code to the top of
// LoadPackageInternal inside UObjectGlobals.cpp
//
// if (PackagePath.GetLocalFullPath().Contains("MyAsset"))
// {
// UE_LOG(LogTemp, Log, TEXT("Set Breakpoint Here"));
// }
//
//----------------------------------------------------------------------------------------------------------
UObject* FLinkerLoad::CreateExportAndPreload(int32 ExportIndex, bool bForcePreload /* = false */)
{
UObject *Object = CreateExport(ExportIndex);
const bool IsMyAsset = Object && Object->GetName().Contains("MyAsset"); // << NEW
bForcePreload |= MyAsset; // << NEW
if (Object && (bForcePreload || dynamic_cast<UClass*>(Object) || Object->IsTemplate() || dynamic_cast<UObjectRedirector*>(Object)))
{
if (IsMyAsset) // << NEW
{ // << NEW
UE_LOG(LogTemp, Log, TEXT("Set Breakpoint Here")); // << NEW
} // << NEW
Preload(Object);
}
return Object;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment