Last active
September 23, 2022 12:41
-
-
Save tmsampson/96648274b78103067bf8360597e493e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//---------------------------------------------------------------------------------------------------------- | |
// 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