I am trying to create PCGVolume programmatically in the following way:
#CustomPCGVolume.h
#pragma once
#include "CoreMinimal.h"
#include "PCGVolume.h"
#include "Components/BoxComponent.h"
#include "CustomPCGVolume.generated.h"
UCLASS()
class TESTSPLINEACTOR_API ACustomPCGVolume : public APCGVolume
{
GENERATED_BODY()
public:
ACustomPCGVolume(const FObjectInitializer& ObjectInitializer);
// Box component to define the bounds of the PCGVolume
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
UBoxComponent* BoxComponent;
};
# CustomPCGVolume.cpp
#include "CustomPCGVolume.h"
ACustomPCGVolume::ACustomPCGVolume(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
// Create the BoxComponent and attach it to the root component
BoxComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxComponent"));
BoxComponent->SetupAttachment(RootComponent); // Attach to the root component of the PCGVolume
// Set the default extent of the box component
BoxComponent->SetBoxExtent(FVector(3000.0f, 3000.0f, 500.0f)); // Example half extents
BoxComponent->SetVisibility(true); // Make the component visible in the editor
BoxComponent->SetHiddenInGame(false); // Ensure it is not hidden during gameplay
}
But when I attach PCGGraph to this volume and try to generate content (for the sake of simplicity, I do this in editor) - nothing happens. Judging by results of PCGVolume->GetBounds(), it seems that created volume has zero size.
The same PCG graph works well with PCGVolume created manually in the editor.
Is there any way to fix the problem? Perhaps it’s somehow possible to debug what exactly is going wrong.
Any help would be appreciated.