I tried to spawn BP class from C++. My code is here:
TSubclassOf<class AWall> wallClass;
UMazeLib::UMazeLib() {
static ConstructorHelpers::FObjectFinder<UBlueprint> wallBP(TEXT("Blueprint'/Game/BP_Wall.BP_Wall'"));
if (wallBP.Object) {
wallClass = (UClass*)wallBP.Object->GeneratedClass;
}
}
void UMazeLib::spawnMaze(int size, UWorld* world) {
bool** maze = generateMaze(size);
for (int h = 0; h < size; h++)
{
for (int w = 0; w < size; w++)
{
if (maze[h][w]) {
int x = h * 100;
int y = w * 100;
const FVector* position = new FVector(x, y, 0);
AActor* spawnedWall = world->SpawnActor(wallClass, position);
spawnedWall->SetActorHiddenInGame(false);
}
}
}
}
But it spawns actor invisible, and after I return from play mode to editor, they shows me.