참고한 자료 : https://www.youtube.com/watch?v=Ijpa9mI2b5I&t=4s
AActor* FNightButtonModule::AddActor(TSubclassOf<AActor> ActorClass){
ULevel* level = GEditor->GetEditorWorldContext().World()->GetCurrentLevel();
return GEditor->AddActor(level,ActorClass, FTransform());
}
AActor* FNightButtonModule::FindActor(TSubclassOf<AActor> ActorClass)
{
TArray<AActor*> FoundActors;
UWorld* World = GEditor->GetEditorWorldContext().World();
if(World){
UGameplayStatics::GetAllActorsOfClass(World,ActorClass,FoundActors);
if(FoundActors.Num()>0){
return FoundActors[0];
}
}
return nullptr;
}
FText DialogText = FText::FromString("Changing scene to Night");
FoundActor = FindActor(APostProcessVolume::StaticClass());
APostProcessVolume* PPVol;
if(!FoundActor){
DialogText = FText::FromString("PostProcessVolume Not Found, Creating One");
FMessageDialog::Open(EAppMsgType::Ok, DialogText);
FoundActor = AddActor(APostProcessVolume::StaticClass());
}
PPVol = Cast<APostProcessVolume>(FoundActor);
PPVol->Settings.AutoExposureBias = -3.f;
PPVol->Settings.bOverride_AutoExposureBias = true;
PPVol->bUnbound = true;