In my Test Project, I have an Actor that creates a UStaticMesh from a Brush. This compiles fine on Linux but in Windows I get the following error message:
How can I solve this Problem? Here is my code.
TestActor.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "TestActor.generated.h"
UCLASS()
class TESTPROJECT_API ATestActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ATestActor();
virtual void PostActorCreated() override;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
TestActor.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "TestActor.h"
#include "Editor/UnrealEd/Classes/Builders/CubeBuilder.h"
// Sets default values
ATestActor::ATestActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void ATestActor::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ATestActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ATestActor::PostActorCreated()
{
UStaticMesh* StaticMesh = nullptr;
UWorld *World = GEditor->GetEditorWorldContext().World();
ABrush* DefBrush = World->GetDefaultBrush();
DefBrush->BrushBuilder = NewObject<UCubeBuilder>(DefBrush,"CubeBuilder");
DefBrush->BrushBuilder->Build(World, DefBrush);
DefBrush->SetNeedRebuild(DefBrush->GetLevel());
GEditor->RebuildAlteredBSP();
UE_LOG(LogTemp, Warning, TEXT("1"));
CreateStaticMeshFromBrush(this, TEXT("Test"),World->GetDefaultBrush(), World->GetDefaultBrush()->Brush);
UE_LOG(LogTemp, Warning, TEXT("2"));
}
TestProject.Build.cs:
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class TestProject : ModuleRules
{
public TestProject(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UnrealEd" });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}