Add a blueprint exporter for claude code
This commit is contained in:
@@ -3,4 +3,56 @@
|
||||
#include "Integration.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, Integration, "Integration" );
|
||||
#if WITH_EDITOR
|
||||
#include "Engine/Blueprint.h"
|
||||
#include "UObject/SavePackage.h"
|
||||
#include "UObject/ObjectSaveContext.h"
|
||||
#include "EdGraph/EdGraph.h"
|
||||
#include "BlueprintExporter.h"
|
||||
#include "Misc/FileHelper.h"
|
||||
#endif
|
||||
|
||||
IMPLEMENT_PRIMARY_GAME_MODULE(FlxIntegrationModuleImpl, Integration, "Integration");
|
||||
|
||||
void FlxIntegrationModuleImpl::StartupModule()
|
||||
{
|
||||
#if WITH_EDITOR
|
||||
OnAssetSavedHandle = UPackage::PackageSavedWithContextEvent.AddRaw(
|
||||
this, &FlxIntegrationModuleImpl::OnAssetSaved);
|
||||
#endif
|
||||
}
|
||||
|
||||
void FlxIntegrationModuleImpl::ShutdownModule()
|
||||
{
|
||||
#if WITH_EDITOR
|
||||
UPackage::PackageSavedWithContextEvent.Remove(OnAssetSavedHandle);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
void FlxIntegrationModuleImpl::OnAssetSaved(const FString& PackageFilename, UPackage* Package, FObjectPostSaveContext Context)
|
||||
{
|
||||
if (!Package) return;
|
||||
|
||||
ForEachObjectWithPackage(Package, [&](UObject* Object)
|
||||
{
|
||||
if (UBlueprint* BP = Cast<UBlueprint>(Object))
|
||||
{
|
||||
FString BPDir = FPaths::ProjectDir() / TEXT("Saved") / TEXT("BlueprintExports") / BP->GetName();
|
||||
|
||||
TArray<UEdGraph*> AllGraphs;
|
||||
BP->GetAllGraphs(AllGraphs);
|
||||
|
||||
for (UEdGraph* Graph : AllGraphs)
|
||||
{
|
||||
FlxBlueprintExporter Exporter(Graph);
|
||||
|
||||
FString FilePath = BPDir / Graph->GetName() + TEXT(".txt");
|
||||
FFileHelper::SaveStringToFile(Exporter.GetOutput(), *FilePath);
|
||||
UE_LOG(LogTemp, Warning, TEXT("Blueprint export: %s"), *FilePath);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user