Any way to access Blueprint class node anonymous variables through reflection?

I figured it out.

Blueprint local variables are stored in the Ubergraph Persistent Frame.

if (UBlueprintGeneratedClass* BlueprintGeneratedClass = Cast<UBlueprintGeneratedClass>(Object->GetClass()))
{
	if (UFunction* UbergraphFunction = BlueprintGeneratedClass->UberGraphFunction)
	{
		uint8* FramePtr = BlueprintGeneratedClass->GetPersistentUberGraphFrame(Object, UbergraphFunction);
		for (TFieldIterator<FProperty> PropIt(UbergraphFunction); PropIt; ++PropIt)
		{
			const FProperty* Property = *PropIt;
			const void* PropData = Property->ContainerPtrToValuePtr<uint8>(FramePtr);

			// TODO: Do something with Property and PropData
		}
	}
}

I hadn’t realised just how much state Blueprint graphs keep.
A lot of the logic is in macros which use local variables, but they don’t (and can’t) actually use the persistent flag, so it just stores everything. DoOnce and FlipFlops and Gates, but also the counters for loops, the return values of every node, etc.

That does reveal one major problem with the idea of saving these values - none of them have unique names, which means that saving them would be really fragile.
Saving “Blueprint boolean property #5” is all very well, but it quickly falls apart if the Blueprint graph changes and the numbers no longer align with the old save.

1 Like